Skip to content

Commit 0cede86

Browse files
committed
fixup! test: add regression test for using ObjectWrap in worker
1 parent fcb0a4d commit 0cede86

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
const common = require('../../common');
3+
const { isMainThread, Worker } = require('worker_threads');
4+
5+
if (!isMainThread) {
6+
const addon = require(`./build/${common.buildType}/binding`);
7+
8+
9+
// Create some garbage
10+
const arr = [];
11+
for (let i = 0; i < 1e5; i++) arr.push(`${i}`.repeat(100));
12+
13+
new addon.MyObject(10);
14+
15+
// Should not segfault
16+
throw new Error('exit');
17+
} else {
18+
const worker = new Worker(__filename);
19+
worker.on('error', common.mustCall(() => {}));
20+
}

test/addons/worker-addon-exit/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ if (!isMainThread) {
1111
throw new Error('exit');
1212
} else {
1313
const worker = new Worker(__filename);
14-
worker.on('error', () => {});
14+
worker.on('error', common.mustCall(() => {}));
1515
}

0 commit comments

Comments
 (0)