Skip to content

Commit 09323d9

Browse files
test(server): dispose the orphan-teardown test worker on failure
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 17b58ca commit 09323d9

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

‎apps/server/src/speech/native.test.ts‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,19 @@ it("kills a hung streaming feed without waiting for native cleanup", async () =>
163163
it("skips process exit teardown when the backend dies during native inference", async () => {
164164
const directory = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3code-speech-orphan-"));
165165
const marker = NodePath.join(directory, "exit-teardown");
166+
// The exit hook stands in for native atexit teardown; the interval for the threadpool call.
167+
const model = await loadNativeSpeechModel(
168+
"unused.gguf",
169+
new AbortController().signal,
170+
streamingFixture(`async () => {
171+
const { writeFileSync } = process.getBuiltinModule("node:fs");
172+
process.once("exit", () => writeFileSync(${JSON.stringify(marker)}, "ran"));
173+
setInterval(() => {}, 1 << 30);
174+
process.disconnect();
175+
return await new Promise(() => {});
176+
}`),
177+
);
166178
try {
167-
// The exit hook stands in for native atexit teardown; the interval for the threadpool call.
168-
const model = await loadNativeSpeechModel(
169-
"unused.gguf",
170-
new AbortController().signal,
171-
streamingFixture(`async () => {
172-
const { writeFileSync } = process.getBuiltinModule("node:fs");
173-
process.once("exit", () => writeFileSync(${JSON.stringify(marker)}, "ran"));
174-
setInterval(() => {}, 1 << 30);
175-
process.disconnect();
176-
return await new Promise(() => {});
177-
}`),
178-
);
179179
await model.begin({ timestamps: "none" }, false);
180180
await expect(model.feed(new Float32Array(512).fill(0.25))).rejects.toThrow(
181181
"Speech process exited",
@@ -185,6 +185,7 @@ it("skips process exit teardown when the backend dies during native inference",
185185
"orphaned worker ran exit teardown while native inference was in flight",
186186
).toBe(false);
187187
} finally {
188+
await model.dispose();
188189
NodeFS.rmSync(directory, { recursive: true, force: true });
189190
}
190191
});

0 commit comments

Comments
 (0)