Using the latest version of Acorn (5.1.2, and also previous v4) we’re encountering a very odd problem.
For what appears to be a valid JS file, we get an “Unexpected Token” error pointing at the last line of the file.
It is always on the last line
There are no odd hex characters at the end, or other unusual line endings.
The odd thing is that this is not a reliable problem. If I try to reproduce this outside of a full system test then there is no problem. Adding extra debug lines can make the problem go away. Even with the system test, there’s about a 90% chance of reproduction.
I’ve confirmed (printint in hex) that the input is the same to Acorn each time.
Based on past experience, in same the Java world, this would indicate to me a timing or threading issues. But this is in Node (version independant it would seem).
Any thoughts on how to debug this further would be appreciated.