Skip to content

Commit b2ca0d5

Browse files
test: restore forceStop() where crash/abrupt-disconnect semantics matter
Keep graceful stop() for normal teardown (needed so in-process workers release handles and exit), but revert to forceStop() where the test intent requires it: - client.e2e 'should forceStop without cleanup' body - connection_token unauthenticated clients whose start() rejects - client.test.ts stdin-error test using a mock connection - pending_work_resume, which forceStop()s to simulate a crash leaving pending work for resume (restored to base) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 496818e commit b2ca0d5

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

nodejs/test/client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function stopClient(client: CopilotClient): Promise<void> {
2626
describe("CopilotClient", () => {
2727
it("disposes the stdio connection when child stdin emits an error", async () => {
2828
const client = new CopilotClient();
29-
onTestFinished(() => stopClient(client));
29+
onTestFinished(() => client.forceStop());
3030

3131
const stdin = new PassThrough();
3232
const stdout = new PassThrough();

nodejs/test/e2e/client.e2e.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe("Client", () => {
111111
onTestFinishedForceStop(client);
112112

113113
await client.createSession({ onPermissionRequest: approveAll });
114-
await client.stop();
114+
await client.forceStop();
115115
});
116116

117117
it("should get status with version and protocol info", async () => {

nodejs/test/e2e/connection_token.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ describe("Connection token", async () => {
2424
});
2525

2626
afterAll(async () => {
27-
await wrongClient.stop();
28-
await noTokenClient.stop();
27+
await wrongClient.forceStop();
28+
await noTokenClient.forceStop();
2929
});
3030

3131
it("connects with the matching token", async () => {

nodejs/test/e2e/pending_work_resume.e2e.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe("Pending work resume", async () => {
150150
});
151151
onTestFinished(async () => {
152152
try {
153-
await server.stop();
153+
await server.forceStop();
154154
} catch {
155155
// Ignore cleanup errors
156156
}
@@ -164,7 +164,7 @@ describe("Pending work resume", async () => {
164164
});
165165
onTestFinished(async () => {
166166
try {
167-
await client.stop();
167+
await client.forceStop();
168168
} catch {
169169
// Ignore cleanup errors
170170
}
@@ -222,7 +222,7 @@ describe("Pending work resume", async () => {
222222
await permissionRequestedP;
223223
expect(initialRequest.kind).toBe("custom-tool");
224224

225-
await suspendedClient.stop();
225+
await suspendedClient.forceStop();
226226

227227
const resumedTcpClient = createConnectingClient(cliUrl);
228228
const session2 = await resumedTcpClient.resumeSession(sessionId, {
@@ -300,7 +300,7 @@ describe("Pending work resume", async () => {
300300
)
301301
).toBe("beta");
302302

303-
await suspendedClient.stop();
303+
await suspendedClient.forceStop();
304304

305305
const resumedClient = createConnectingClient(cliUrl);
306306
const session2 = await resumedClient.resumeSession(sessionId, {
@@ -379,7 +379,7 @@ describe("Pending work resume", async () => {
379379
expect(await originalToolAStarted.promise).toBe("alpha");
380380
expect(await originalToolBStarted.promise).toBe("beta");
381381

382-
await suspendedClient.stop();
382+
await suspendedClient.forceStop();
383383

384384
const resumedClient = createConnectingClient(cliUrl);
385385
const session2 = await resumedClient.resumeSession(sessionId, {
@@ -434,7 +434,7 @@ describe("Pending work resume", async () => {
434434
expect(firstAnswer?.data.content ?? "").toContain("NO_PENDING_TURN_ONE");
435435

436436
await firstSession.disconnect();
437-
await firstClient.stop();
437+
await firstClient.forceStop();
438438
}
439439

440440
const resumedClient = createConnectingClient(cliUrl);
@@ -516,7 +516,7 @@ describe("Pending work resume", async () => {
516516
).toBe("beta");
517517

518518
if (scenario.disconnectOriginalClient) {
519-
await suspendedClient.stop();
519+
await suspendedClient.forceStop();
520520
}
521521

522522
const resumedClient = createConnectingClient(cliUrl);
@@ -615,7 +615,7 @@ describe("Pending work resume", async () => {
615615
);
616616

617617
await firstSession.disconnect();
618-
await firstClient.stop();
618+
await firstClient.forceStop();
619619
}
620620

621621
const resumedClient = createConnectingClient(cliUrl);

0 commit comments

Comments
 (0)