mirror of
https://github.com/morluto/rea
synced 2026-10-28 15:07:26 -04:00
test(javascript): synchronize worker cleanup and validate candidate facts
This commit is contained in:
@@ -162,10 +162,14 @@ it("ends worker stdin and unreferences process handles when cleanup reports insp
|
||||
let unreferenced = false;
|
||||
let permitCleanup = false;
|
||||
let childStdin: typeof process.stdin | undefined;
|
||||
let childExit: Promise<void> | undefined;
|
||||
const worker = new JavaScriptAnalysisWorker(
|
||||
{ heapMb: 128, timeoutMs: 30_000 },
|
||||
async (request) => {
|
||||
const launched = await spawnOwnedProviderProcess(request);
|
||||
childExit = new Promise((resolve) => {
|
||||
launched.process.once("exit", () => resolve());
|
||||
});
|
||||
const originalUnref = launched.process.unref;
|
||||
launched.process.unref = () => {
|
||||
unreferenced = true;
|
||||
@@ -208,6 +212,7 @@ it("ends worker stdin and unreferences process handles when cleanup reports insp
|
||||
expect(childStdin?.listenerCount("error")).toBeLessThanOrEqual(
|
||||
errorListeners ?? 0,
|
||||
);
|
||||
await childExit;
|
||||
permitCleanup = true;
|
||||
await worker.close();
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user