Skip to content
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

lz4wasm catches UnhandledPromiseRejectionWarning and exits node process #6

Open
khelkun opened this issue Aug 27, 2020 · 4 comments · May be fixed by #7
Open

lz4wasm catches UnhandledPromiseRejectionWarning and exits node process #6

khelkun opened this issue Aug 27, 2020 · 4 comments · May be fixed by #7

Comments

@khelkun
Copy link

khelkun commented Aug 27, 2020

Inside a non terminating program (like an expressjs server). Without require('lz4-asm') module the instruction new Promise((resolve, reject) => { throw new Error("my promise thrown error"); }); produces the following output and does not end the nodejs process:

(node:15532) UnhandledPromiseRejectionWarning: Error: my promise thrown error
    at interfaces.start (G:\algorithm-scheduler\svc\interface.js:43:40)
    at new Promise (<anonymous>)
    at Object.<anonymous> (G:\algorithm-scheduler\svc\interface.js:43:1)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14)
    at Module.require (internal/modules/cjs/loader.js:1012:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (G:\algorithm-scheduler\svc\entrypoints.js:8:23)
(node:15532) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15532) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code

But if I require('lz4-asm') in my program, then the same instruction produces the following output and ends the nodejs process:

Error: my promise thrown error
    at G:\VIZUA\gitlab\3dverse\algobelt\algorithm-scheduler\svc\interface.js:43:40
    at new Promise (<anonymous>)
    at Object.<anonymous> (G:\VIZUA\gitlab\3dverse\algobelt\algorithm-scheduler\svc\interface.js:43:1)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14)
    at Module.require (internal/modules/cjs/loader.js:1012:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (G:\VIZUA\gitlab\3dverse\algobelt\algorithm-scheduler\svc\entrypoints.js:8:23)
Error: my promise thrown error
    at G:\VIZUA\gitlab\3dverse\algobelt\algorithm-scheduler\svc\interface.js:43:40
    at new Promise (<anonymous>)
    at Object.<anonymous> (G:\VIZUA\gitlab\3dverse\algobelt\algorithm-scheduler\svc\interface.js:43:1)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14)
    at Module.require (internal/modules/cjs/loader.js:1012:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (G:\VIZUA\gitlab\3dverse\algobelt\algorithm-scheduler\svc\entrypoints.js:8:23)
G:\VIZUA\gitlab\3dverse\algobelt\algorithm-scheduler\node_modules\lz4-asm\dist\lz4wasm.js:12
if(r)t=q?require("path").dirname(t)+"/":__dirname+"/",u=function(a,b){w||(w=require("fs"));x||(x=require("path"));a=x.normalize(a);return w.readFileSync(a,b?null:"utf8")},v=function(a){a=u(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||y("Assertion failed: undefin
ed");return a},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(a){if(!(a instanceof z))throw a;}),process.on("unhandledRejection",y),n=function(a){process.exit(a)},

                                                                                                                                                               ^

RuntimeError: abort(Error: my promise thrown error). Build with -s ASSERTIONS=1 for more info.
    at process.y (G:\VIZUA\gitlab\3dverse\algobelt\algorithm-scheduler\node_modules\lz4-asm\dist\lz4wasm.js:16:393)
    at process.emit (events.js:315:20)
    at processPromiseRejections (internal/process/promises.js:209:33)
    at processTicksAndRejections (internal/process/task_queues.js:98:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! algorithm-scheduler@0.1.0 start: `node svc/main.js`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the algorithm-scheduler@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\sebtr\AppData\Roaming\npm-cache\_logs\2020-08-27T15_25_02_512Z-debug.log

I tried to figure out where this comes from and how to disable it but I failed. Could you help me please?

@khelkun khelkun changed the title lz4wasm catches UnhandledPromiseRejectionWarning then asserts then exit node process lz4wasm catches UnhandledPromiseRejectionWarning and exits node process Aug 27, 2020
@khelkun
Copy link
Author

khelkun commented Aug 27, 2020

this could be related:
emscripten-core/emscripten#11768

and the workaround would be:
emscripten-core/emscripten#9061

@STUkh @ukyo
Would it be a problem to add -s NODEJS_CATCH_REJECTION=0 to the RELEASE_ARGS of your gulp/emscripten.js ?

@STUkh STUkh linked a pull request Sep 5, 2020 that will close this issue
@STUkh
Copy link
Contributor

STUkh commented Sep 5, 2020

@khelkun created PR to resolve this issue. Nice catch!

@galrose
Copy link

galrose commented Jun 26, 2022

@STUkh Hey is this being worked on?

@STUkh
Copy link
Contributor

STUkh commented Jun 26, 2022

@galrose It was resolved but I don't see @ukyo merged it. So you can use code with this PR: #7
I recently tried to re-compile this project with latest emcc and it fail with asm build, but wasm is 100% ok. So you can try it out - it works flawlessly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants