-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SyntaxError: Invalid or unexpected token #41
Comments
Sometimes those errors don't occur, it's just random |
Do i need to require bytenode in every file? |
Could you please provide an example that reproduce the issue?
In general, no. But as your app is using workers I need to see an example. |
my express setup is basically it:
And there is some routes for my API. Using express Router. For my workers, i use this little script i wrote to help me both on development and production (this one i leave as a .js because i need some .js for the workerPath:
I use socket.io too, and i got the same message on the errors "Invalid or unexpected token". Notice that i said the program starts normal and after running for one minute or so, those errors start to appear until the program crashes. And sometimes those errors appears just when i start and access some route or my worker/main thread exchange data. (Sorry if i wrote something wrong, my english is not 100%) |
Your example isn't clear. Please provide a complete workable example, with filenames and the compiling process itself. |
I don't have much time today. But do you have any idea of what is happening? Or node version recomendation. I'm currently using v12.13.0 |
Take your time. I don't know what or where does your issue come from without a complete example that reproduce the error. |
But basically i compile every .js of my project using bytenode.compileFile, including the main index.js and except that one i use to start a worker. |
It's not clear how your worker file will call the express server. Without a complete example that I can run with a simple Just make a very minimal example that contains |
Oh, my worker is just a part of my project, they are are not related, they just happen to run in the same project |
But after tomorrow i'll test if a simple express server throw those errors, if it does, i'm missing something |
I read the README, and i missed two things:
I'll make those changes tomorrow and see if makes difference. |
We don't have a simple re-create but we are also hitting this error. We are also using an express app. |
As I mentioned above, without a concrete example there is a little that we can do. You may email me with more details on your source code and the issue that you have if you can't disclose such details here. |
@IBMRob are you using docker to run your application? because i am. It seems it is not a normal problem |
@WilianZilv - Yes - we only see the problem when running it in a docker container/openshift. When we run it locally it all works fine. |
Ok. That's a good starting point. I will look into it. |
Are you sure that Node.js version and arch is the same locally and in docker? |
In my case i share my project folder to a container that uses the same image as the other container uses to run the application and then i compile the scripts there. So the node version and system match |
Yup We are using the same docker image for both compiling and running - registry.access.redhat.com/ubi8/nodejs-12 |
I coudn't reproduce my issue... It's so weird. |
same problem here, node12 + babel+es6 syntax. PS: NO Problem when using node10 + babel+es6 syntax, I can only reproduce this problem with node12
|
@yingjun Can you email me with a minimal reproducible example? |
@OsamaAbbas |
Same here, i can't reproduce the issue with a minimal example |
We think this might be a problem with express where it doesn't allow minification of comments i.e. it has:
at the top of all its |
But the express module itself is not compiled to bytenode |
Agreed. I can only post what we have found to fix it. |
This is strange, because v8 minify the code before compiling it, and I don't think it respects this It is also strange because I have compiled express before, never had any problems. But at least we have now a concret case to test and try. Thank you. |
I tried to reproduce this issue and failed again. Can you provide me with your complete setup (with a simple "hello world" server), that reproduce the error? @IBMRob |
So unfortunately although this change worked for us for a few days, suddenly we are starting to hit it again so the fix above certainly isn't a fix :( We have not managed to get a simple re-create yet. Its certainly a Node12 issue as moving back to Node10 works-around the problem. |
Hi, I guess you get this problem due to bytecode flushing, just try this solution:
|
We have discussed flushing here: #36 . It seems that my previous analysis was wrong though. Thank you for your comment. I hope @WilianZilv and @IBMRob find that flag useful for their issue. |
I was having the same issues described in this thread too. |
Fine. I will wait until WilianZilv and IBMRob responde, then I will publish a new version that sets this flag in bytenode itself. I will update README.md too to reflect this issue. |
I will wait for two more days or so, then I will close this issue due to inactivity. |
Using |
Sending messages to worker:
Express random error when i enter a route that doesn't exists
This is one of the many errors i get when i run my project compiled with bytenode. Any help? My project is stable with the source code. But i need to protect it.
The text was updated successfully, but these errors were encountered: