bytenode: SyntaxError: Invalid or unexpected token

Sending messages to worker:

(node:30) UnhandledPromiseRejectionWarning: SyntaxError: Invalid or unexpected token
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:30) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

Express random error when i enter a route that doesn’t exists

SyntaxError: Invalid or unexpected token
    at Layer.handle [as handle_request] (/sistema/server/node_modules/express/lib/router/layer.js:95:5)
    at next (/sistema/server/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/sistema/server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/sistema/server/node_modules/express/lib/router/layer.js:95:5)
    at /sistema/server/node_modules/express/lib/router/index.js:281:22
    at param (/sistema/server/node_modules/express/lib/router/index.js:354:14)
    at param (/sistema/server/node_modules/express/lib/router/index.js:365:14)
    at Function.process_params (/sistema/server/node_modules/express/lib/router/index.js:410:3)
    at next (/sistema/server/node_modules/express/lib/router/index.js:275:10)
    at SendStream.error (/sistema/server/node_modules/serve-static/index.js:121:7)
    at SendStream.emit (events.js:210:5)
    at SendStream.error (/sistema/server/node_modules/send/index.js:270:17)
    at SendStream.onStatError (/sistema/server/node_modules/send/index.js:421:12)
    at next (/sistema/server/node_modules/send/index.js:735:16)
    at onstat (/sistema/server/node_modules/send/index.js:724:14)
    at FSReqCallback.oncomplete (fs.js:158:21)

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.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 38

Most upvoted comments

Using --no-flush-bytecode on the bytenode command line has also resolved this issue for us too. If there is a way to always do this so we don’t need to have custom command lines it would be good

Hi, I guess you get this problem due to bytecode flushing, just try this solution:

const v8 = require('v8');
v8.setFlagsFromString('--no-flush-bytecode');

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 was having the same issues described in this thread too. Setting --no-flush-bytecode as suggested by @a-parser seems to have fixed it for me.

We think this might be a problem with express where it doesn’t allow minification of comments i.e. it has:

/*!
 * express
 * Copyright(c) 2009-2013 TJ Holowaychuk
 * Copyright(c) 2013 Roman Shtylman
 * Copyright(c) 2014-2015 Douglas Christopher Wilson
 * MIT Licensed
 */

at the top of all its .js files. If you replace the /*! with /** we no longer see the problem.

@OsamaAbbas I cannot reproduce it with minimal code not sure what was the problem. but I can confirm that this problem is only occurred when use node v12