mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 00:55:45 +00:00

Rather than passing errors using some sort of string representation, do a best effort for faithful serialization/deserialization of uncaught exception objects. PR-URL: https://github.com/nodejs/node/pull/20876 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
20 lines
546 B
JavaScript
20 lines
546 B
JavaScript
// Flags: --experimental-worker
|
|
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker } = require('worker');
|
|
|
|
// Do not use isMainThread so that this test itself can be run inside a Worker.
|
|
if (!process.env.HAS_STARTED_WORKER) {
|
|
process.env.HAS_STARTED_WORKER = 1;
|
|
const w = new Worker(__filename);
|
|
w.on('message', common.mustNotCall());
|
|
w.on('error', common.mustCall((err) => {
|
|
assert(/^Error: foo$/.test(err));
|
|
}));
|
|
} else {
|
|
setImmediate(() => {
|
|
throw new Error('foo');
|
|
});
|
|
}
|