Skip to content

Commit 919fd3c

Browse files
authored
fix: close REPL servers after each test to prevent Jest worker from hanging
Agent-Logs-Url: https://github.com/counterfact/api-simulator/sessions/6ff99a5b-2b06-4f18-b2a7-2b880122ff00
1 parent 5ae875a commit 919fd3c

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)