This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 deletions

21
node_modules/piscina/test/messages.test.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { resolve } from 'node:path';
import { once } from 'node:events';
import Piscina from '..';
test('Pool receive message from workers', async () => {
const pool = new Piscina({
filename: resolve(__dirname, 'fixtures/eval.js')
});
const messagePromise = once(pool, 'message');
const taskResult = pool.run(`
require('worker_threads').parentPort.postMessage("some message");
42
`);
assert.strictEqual(await taskResult, 42);
assert.strictEqual((await messagePromise)[0], 'some message');
});