mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
e8f3119190
Check that main thread handles an unknown message type from a worker thread as expected. PR-URL: https://github.com/nodejs/node/pull/27995 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
25 lines
721 B
JavaScript
25 lines
721 B
JavaScript
'use strict';
|
|
|
|
// Flags: --expose-internals
|
|
|
|
// Check that main thread handles unserializable errors in a worker thread as
|
|
// expected.
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const { Worker } = require('worker_threads');
|
|
|
|
const worker = new Worker(`
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const { getEnvMessagePort } = internalBinding('worker');
|
|
const { messageTypes } = require('internal/worker/io');
|
|
const messagePort = getEnvMessagePort();
|
|
messagePort.postMessage({ type: messageTypes.COULD_NOT_SERIALIZE_ERROR });
|
|
`, { eval: true });
|
|
|
|
worker.on('error', common.mustCall((e) => {
|
|
assert.strictEqual(e.code, 'ERR_WORKER_UNSERIALIZABLE_ERROR');
|
|
}));
|