diff --git a/src/javascript/sourceMaps/SourceMapCommand.test.ts b/src/javascript/sourceMaps/SourceMapCommand.test.ts index 3194c025e4..5ea4cabc12 100644 --- a/src/javascript/sourceMaps/SourceMapCommand.test.ts +++ b/src/javascript/sourceMaps/SourceMapCommand.test.ts @@ -7,7 +7,6 @@ import * as processOutput from "../../process/ExecFileOutput.js"; import { AnalysisCancelledError, AnalysisResourceConstraintError, - AnalysisTimeoutError, } from "../../domain/analysisErrorCore.js"; import { PrivateRuntimeRoot } from "../../process/PrivateRuntimeRoot.js"; import { @@ -406,31 +405,3 @@ it.each([ expect(result.error.secondaryFailures[0]?.cause).toBe(reason); }, ); - -it("keeps an observed launcher interruption at the codec deadline a timeout", async () => { - vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "performance"] }); - try { - const result = await runSourceMapCommand( - "{}", - "/probe/source.map", - undefined, - { - prepareOwnership: async () => {}, - launcher: async ({ signal }) => { - await vi.advanceTimersByTimeAsync(1000); - assertProcessOwnershipInspectionActive(signal); - throw new Error( - "expected the codec deadline to interrupt the launcher", - ); - }, - }, - unexpectedCleanup, - 1000, - ); - if (result.ok) throw new Error("expected launch timeout"); - expect(result.error).toBeInstanceOf(AnalysisTimeoutError); - expect(result.error.secondaryFailures).toHaveLength(0); - } finally { - vi.useRealTimers(); - } -}); diff --git a/tests/boundary/javascript/sourceMapDecoder.test.ts b/tests/boundary/javascript/sourceMapDecoder.test.ts index d89d925f3e..f939686fa5 100644 --- a/tests/boundary/javascript/sourceMapDecoder.test.ts +++ b/tests/boundary/javascript/sourceMapDecoder.test.ts @@ -159,39 +159,47 @@ it.each([ ])( "starts the $name codec deadline after ownership preparation", async ({ selected, expectedMs }) => { - vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "performance"] }); + const deadlineStates: (boolean | undefined)[] = []; let path: string | undefined; + const decoder = realDecoder({ + prepareOwnership: async () => { + await vi.advanceTimersByTimeAsync(20_001); + }, + createRuntime: async () => { + const root = await PrivateRuntimeRoot.create(); + path = root.path; + return root; + }, + launcher: async ({ signal }) => { + await vi.advanceTimersByTimeAsync(expectedMs - 1); + deadlineStates.push(signal?.aborted); + await vi.advanceTimersByTimeAsync(1); + deadlineStates.push(signal?.aborted); + assertProcessOwnershipInspectionActive(signal); + throw new Error( + "Expected the codec deadline to interrupt the launcher", + ); + }, + }); + vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "performance"] }); try { - const response = await realDecoder({ - prepareOwnership: async () => { - await vi.advanceTimersByTimeAsync(20_001); - }, - createRuntime: async () => { - const root = await PrivateRuntimeRoot.create(); - path = root.path; - return root; - }, - launcher: async ({ signal }) => { - await vi.advanceTimersByTimeAsync(expectedMs - 1); - expect(signal?.aborted).toBe(false); - await vi.advanceTimersByTimeAsync(1); - expect(signal?.aborted).toBe(true); - throw new Error("launcher settled after deadline"); - }, - }).trace({ + const response = await decoder.trace({ ...input, ...(selected === undefined ? {} : { decodeTimeoutMs: selected }), }); - if (response.ok) throw new Error("expected decode deadline"); + expect(deadlineStates).toEqual([false, true]); + if (response.ok) throw new Error("Expected decode deadline"); expect(response.error).toMatchObject({ _tag: "AnalysisTimeoutError", - userMessage: expect.stringContaining(String(expectedMs)), + timeoutMs: expectedMs, + userMessage: expect.stringContaining("decode_timeout_ms"), + secondaryFailures: [], }); - expect(response.error.userMessage).toContain("decode_timeout_ms"); - if (path === undefined) throw new Error("runtime not acquired"); + if (path === undefined) throw new Error("Runtime not acquired"); await expect(access(path)).rejects.toMatchObject({ code: "ENOENT" }); } finally { vi.useRealTimers(); + await decoder.close(); } }, );