summaryrefslogtreecommitdiff
path: root/test/parallel/test-worker-invalid-workerdata.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-09-09 15:38:48 +0200
committerAnna Henningsen <anna@addaleax.net>2018-09-14 18:55:53 +0200
commitdf7ebfab4e9575eeeb133826c54907053115a0b7 (patch)
treed32a4255b87ec290af5f952c21cf40a202ea5adf /test/parallel/test-worker-invalid-workerdata.js
parent246f6332e5a5f395d1e39a3594ee5d6fe869d622 (diff)
downloadandroid-node-v8-df7ebfab4e9575eeeb133826c54907053115a0b7.tar.gz
android-node-v8-df7ebfab4e9575eeeb133826c54907053115a0b7.tar.bz2
android-node-v8-df7ebfab4e9575eeeb133826c54907053115a0b7.zip
worker: correct (de)initialization order
- Initialize `thread_exit_async_` only once the thread has been started. This is done since it is only triggered from the thread when it is exiting. - Move the final `uv_run` to the `Worker` destructor. This makes sure that it is always run, regardless of whether the thread is actually started or not. - Always dispose the `Isolate` before cleaning up the libuv event loop. This now matches the reverse order of initialization. Fixes: https://github.com/nodejs/node/issues/22736 PR-URL: https://github.com/nodejs/node/pull/22773 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-worker-invalid-workerdata.js')
-rw-r--r--test/parallel/test-worker-invalid-workerdata.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/parallel/test-worker-invalid-workerdata.js b/test/parallel/test-worker-invalid-workerdata.js
new file mode 100644
index 0000000000..d0cb1753eb
--- /dev/null
+++ b/test/parallel/test-worker-invalid-workerdata.js
@@ -0,0 +1,15 @@
+// Flags: --experimental-worker
+'use strict';
+require('../common');
+const assert = require('assert');
+const { Worker } = require('worker_threads');
+
+// This tests verifies that failing to serialize workerData does not keep
+// the process alive.
+// Refs: https://github.com/nodejs/node/issues/22736
+
+assert.throws(() => {
+ new Worker('./worker.js', {
+ workerData: { fn: () => {} }
+ });
+}, /DataCloneError/);