diff options
author | Denys Otrishko <shishugi@gmail.com> | 2018-07-13 18:45:18 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-07-14 12:04:54 +0200 |
commit | 7c2925e60956019fa4ca7bbcafcb98ea79022710 (patch) | |
tree | 7d98e9ea43a02182e3fee966a079053e98758760 /test/parallel/test-worker-uncaught-exception-async.js | |
parent | 19e10ec2e2cb3bf5dbe3110ee49e32dcb3d0fdea (diff) | |
download | android-node-v8-7c2925e60956019fa4ca7bbcafcb98ea79022710.tar.gz android-node-v8-7c2925e60956019fa4ca7bbcafcb98ea79022710.tar.bz2 android-node-v8-7c2925e60956019fa4ca7bbcafcb98ea79022710.zip |
worker: exit after uncaught exception
Previously even after uncaught exception the worker would continue to
execute until there is no more work to do.
PR-URL: https://github.com/nodejs/node/pull/21739
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-worker-uncaught-exception-async.js')
-rw-r--r-- | test/parallel/test-worker-uncaught-exception-async.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/parallel/test-worker-uncaught-exception-async.js b/test/parallel/test-worker-uncaught-exception-async.js index f820976c11..862b1a66d6 100644 --- a/test/parallel/test-worker-uncaught-exception-async.js +++ b/test/parallel/test-worker-uncaught-exception-async.js @@ -10,6 +10,7 @@ if (!process.env.HAS_STARTED_WORKER) { const w = new Worker(__filename); w.on('message', common.mustNotCall()); w.on('error', common.mustCall((err) => { + console.log(err.message); assert(/^Error: foo$/.test(err)); })); w.on('exit', common.mustCall((code) => { @@ -17,6 +18,19 @@ if (!process.env.HAS_STARTED_WORKER) { assert.strictEqual(code, 1); })); } else { + // cannot use common.mustCall as it cannot catch this + let called = false; + process.on('exit', (code) => { + if (!called) { + called = true; + } else { + assert.fail('Exit callback called twice in worker'); + } + }); + + setTimeout(() => assert.fail('Timeout executed after uncaughtException'), + 2000); + setImmediate(() => { throw new Error('foo'); }); |