Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1827256

Browse filesBrowse files
Trotttargos
authored andcommitted
test: add coverage for unserializable worker thread error
Check that the main thread handles unserializable errors in a worker thread as expected. PR-URL: #27995 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent a47ee80 commit 1827256
Copy full SHA for 1827256

File tree

Expand file treeCollapse file tree

1 file changed

+25
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-0
lines changed
Open diff view settings
Collapse file
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
// Flags: --expose-internals
4+
5+
// Check that main thread handles unserializable errors in a worker thread as
6+
// expected.
7+
8+
const common = require('../common');
9+
common.skipIfWorker();
10+
11+
const assert = require('assert');
12+
13+
const { Worker, isMainThread } = require('worker_threads');
14+
if (isMainThread) {
15+
const worker = new Worker(__filename);
16+
worker.on('error', common.mustCall((e) => {
17+
assert.strictEqual(e.code, 'ERR_WORKER_UNSERIALIZABLE_ERROR');
18+
}));
19+
} else {
20+
const { internalBinding } = require('internal/test/binding');
21+
const { getEnvMessagePort } = internalBinding('worker');
22+
const { messageTypes } = require('internal/worker/io');
23+
const messagePort = getEnvMessagePort();
24+
messagePort.postMessage({ type: messageTypes.COULD_NOT_SERIALIZE_ERROR });
25+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.