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('pool worker ref behavior', () => {
12 it('pool keeps event loop alive for top-level await', async () => {
13 const { stdout } = await exec(process.execPath, ['--no-warnings', join(fixturesDir, 'pool-ref-main.ts')], {
14 timeout: 5000,
15 });
16 assert.ok(stdout.includes('DONE'));
17 });
18});