Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/parallel/test-worker-exit-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ const common = require('../common');

const assert = require('assert');
const worker = require('worker_threads');
const { Worker, isMainThread, parentPort } = worker;
const { Worker, parentPort } = worker;

if (isMainThread) {
// 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;
parent();
} else {
if (!parentPort) {
Expand Down
6 changes: 4 additions & 2 deletions test/parallel/test-worker-onmessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker, isMainThread, parentPort } = require('worker_threads');
const { Worker, parentPort } = require('worker_threads');

if (isMainThread) {
// 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.mustCall((message) => {
assert.strictEqual(message, 4);
Expand Down