From 5b5de1b52788c83665e71e54db79472c6205df8b Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Wed, 14 Oct 2026 12:21:22 +0800 Subject: [PATCH] test(javascript): synchronize worker cleanup and validate candidate facts --- .../JavaScriptAnalysisWorkerSchemas.test.ts | 16 ++++++++++++++++ .../javascriptSourceAnalysisWorker.test.ts | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts b/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts index bb6f8b5855..88af2ff6af 100644 --- a/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts +++ b/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts @@ -31,3 +31,19 @@ it("versions fingerprints through the worker schema and rejects v1", () => { false, ); }); + +it("accepts candidate endpoint interpretations from static analysis", () => { + const facts = analyzeJavaScriptStaticSource(`http.request("POST", target);`); + expect(facts.endpoints).toContainEqual( + expect.objectContaining({ + kind: "network", + value: "POST", + interpretation: "candidate", + }), + ); + expect( + javaScriptWorkerStaticAnalysisSchema.safeParse( + JSON.parse(JSON.stringify(facts)) as unknown, + ).success, + ).toBe(true); +}); diff --git a/tests/boundary/javascript/javascriptSourceAnalysisWorker.test.ts b/tests/boundary/javascript/javascriptSourceAnalysisWorker.test.ts index 04ba5201f8..9abf7ab3d7 100644 --- a/tests/boundary/javascript/javascriptSourceAnalysisWorker.test.ts +++ b/tests/boundary/javascript/javascriptSourceAnalysisWorker.test.ts @@ -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 | 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 {