diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-05-11 00:25:49 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-05-15 19:38:26 +0200 |
commit | e65d189e508056e9ce16377bcc42dc02a64e46c6 (patch) | |
tree | 8a1a4a0ac40082a9dd7971df6fa37cebe50f6b85 /test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js | |
parent | fe4e4ddc718a359b97f3fc89e5ff44625dcd6e7d (diff) | |
download | node-new-e65d189e508056e9ce16377bcc42dc02a64e46c6.tar.gz |
test: regression tests for async_hooks + Promise + Worker interaction
Add regression tests for the case in which an async_hook is enabled
inside a Worker thread and `process.exit()` is called during the
async part of an async function.
This commit includes multiple tests that seem like they should all
crash in a similar way, but interestingly don’t. In particular, it’s
surprising that the presence of a statement after `process.exit()`
in a function has an effect on the kind of crash that’s being
exhibited (V8 DCHECK vs. assertion in our own code) and the
circumstances under which it crashes (e.g. the -1 and -2 tests
can be “fixed” by reverting 13c5a1629cd025b, although they
should have the same behavior as the -3 and -4 tests).
PR-URL: https://github.com/nodejs/node/pull/33347
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js')
-rw-r--r-- | test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js b/test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js new file mode 100644 index 0000000000..40c7d85835 --- /dev/null +++ b/test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); +const { Worker } = require('worker_threads'); + +// Like test-async-hooks-worker-promise.js but with an additional statement +// after the `process.exit()` call, that shouldn’t really make a difference +// but apparently does. + +const w = new Worker(` +const { createHook } = require('async_hooks'); + +setImmediate(async () => { + createHook({ init() {} }).enable(); + await 0; + process.exit(); + process._rawDebug('THIS SHOULD NEVER BE REACHED'); +}); +`, { eval: true }); + +w.on('exit', common.mustCall()); |