Files
node/test/parallel/test-worker-invalid-workerdata.js
T
Anna Henningsen df7ebfab4e 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>
2018-09-14 18:55:53 +02:00

16 lines
412 B
JavaScript

// 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/);