Skip to content

Commit 60a320e

Browse files
authored
Merge pull request #1847 from counterfact/copilot/fix-worker-process-exit
fix: close REPL servers after each test to prevent Jest worker from hanging
2 parents d77d0d4 + 919fd3c commit 60a320e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"counterfact": patch
3+
---
4+
5+
Fix Jest worker process failing to exit gracefully by closing REPL servers after each test in the repl test suite.

test/repl/repl.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { REPLServer } from "node:repl";
22

3-
import { jest } from "@jest/globals";
3+
import { afterEach, jest } from "@jest/globals";
44

55
import { createCompleter, startRepl } from "../../src/repl/repl.js";
66
import type { CompleterCallback } from "../../src/repl/repl.js";
@@ -101,9 +101,21 @@ function createHarness(scenarioRegistry?: ScenarioRegistry) {
101101
scenarioRegistry,
102102
);
103103

104+
openServers.push(harness.server);
105+
104106
return { config, contextRegistry, harness, registry };
105107
}
106108

109+
const openServers: REPLServer[] = [];
110+
111+
afterEach(() => {
112+
for (const server of openServers) {
113+
server.close();
114+
}
115+
116+
openServers.length = 0;
117+
});
118+
107119
describe("REPL", () => {
108120
it("turns on the proxy globally", () => {
109121
const { config, harness } = createHarness();

0 commit comments

Comments
 (0)