brfs icon indicating copy to clipboard operation
brfs copied to clipboard

Random "Unexpected token ILLEGAL" error

Open chrisjaure opened this issue 10 years ago • 4 comments

I'm having some trouble pinpointing the exact cause of this error, but I've got 4 bundles and only the one with readFileSync calls fails randomly with this error. In that bundle, there are 7 readFileSync calls in succession. I added some logging and it seems that when this error triggers, the source is mangled and the readFileSync calls are resolved out of order. It only happens once out of 20 or so times.

I'd be happy to debug further, but I'm not sure where to look next or what information you might need.

chrisjaure avatar Apr 09 '15 16:04 chrisjaure

As an example, I added logging in the brfs readFileSync fn for when the stream starts and when it ends. Here is what it looks when everything is fine:

start a
start b
start c
start d
start e
start f
start g
end a
end b
end c
end d
end e
end f
end g

And here's a case where it failed (notice b ends before a and f ends before e):

start a
start b
start c
start d
start e
start f
start g
end b
end a
end c
end d
end f
end e
end g

chrisjaure avatar Apr 09 '15 16:04 chrisjaure

I should also mention that I didn't see this issue in browserify 3.x but only after I upgraded to 9.x so this may actually be a browserify bug.

chrisjaure avatar Apr 09 '15 16:04 chrisjaure

Did some more testing, not sure the order of stream completion matters. Might have just been a coincidence.

However, if I return a string from readFileSync like in https://github.com/substack/brfs/issues/28#issuecomment-84651760 then it works just fine. So it is some sort of stream issue.

chrisjaure avatar Apr 09 '15 22:04 chrisjaure

I am also getting this problem. http://stackoverflow.com/questions/29462510/intermittent-browserify-bundle-failure

Hafthor avatar Apr 14 '15 02:04 Hafthor