Offload functions to worker threads with shared memory primitives for Node.js.
1import { describe, it } from 'node:test';
2import assert from 'node:assert/strict';
3import { execFile } from 'node:child_process';
4import { promisify } from 'node:util';
5import { fileURLToPath } from 'node:url';
6import { join } from 'node:path';
7
8const exec = promisify(execFile);
9const fixturesDir = join(fileURLToPath(import.meta.url), '..', 'fixtures');
10
11describe('streaming process exit', () => {
12 it('process exits after streaming on dedicated worker', async () => {
13 const { stdout } = await exec(
14 process.execPath,
15 ['--no-warnings', '--experimental-strip-types', join(fixturesDir, 'exit-dedicated-main.ts')],
16 { timeout: 5000 },
17 );
18 assert.ok(stdout.includes('DONE'));
19 });
20
21 it('process exits after streaming with pool', async () => {
22 const { stdout } = await exec(
23 process.execPath,
24 ['--no-warnings', '--experimental-strip-types', join(fixturesDir, 'exit-pool-main.ts')],
25 { timeout: 5000 },
26 );
27 assert.ok(stdout.includes('DONE'));
28 });
29});