Skip to content

Commit

Permalink
test: exit sequence sanity tests
Browse files Browse the repository at this point in the history
Execute many module loads in worker in a loop
while exiting from the main thread at arbitrary
execution points, and make sure that the workers
quiesce without crashing.

`worker_threads` are not necessarily the subject of
testing, those are used for easy simulation of
multi-thread scenarios.

Refs: #25007
PR-URL: #25083
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
gireeshpunathil authored and targos committed Jan 29, 2019
1 parent c56ddc7 commit ae19f94
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/parallel/test-worker-cleanexit-with-moduleload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';
require('../common');

// Harden the thread interactions on the exit path.
// Ensure workers are able to bail out safe at
// arbitrary execution points. By using a number of
// internal modules as load candidates, the expectation
// is that those will be at various control flow points
// preferrably in the C++ land.

const { Worker } = require('worker_threads');
for (let i = 0; i < 10; i++) {
new Worker("const modules = ['fs', 'assert', 'async_hooks'," +
"'buffer', 'child_process', 'net', 'http', 'https', 'os'," +
"'path', 'v8', 'vm'];" +
'modules.forEach((module) => {' +
'const m = require(module);' +
'});', { eval: true });
}

// Allow workers to go live.
setTimeout(() => {
process.exit(0);
}, 200);

0 comments on commit ae19f94

Please sign in to comment.