Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions nodejs/test/e2e/harness/sdkTestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,45 @@
await rimraf([join(homeDir, "*"), join(workDir, "*")], { glob: true });
});

afterAll(async () => {

Check failure on line 293 in nodejs/test/e2e/harness/sdkTestContext.ts

View workflow job for this annotation

GitHub Actions / Node.js SDK Tests (windows-latest, inprocess)

test/e2e/session.e2e.test.ts

Error: Hook timed out in 30000ms. If this is a long-running hook, pass a timeout value as the last argument or configure it globally with "hookTimeout". ❯ createSdkTestContext test/e2e/harness/sdkTestContext.ts:293:5 ❯ test/e2e/session.e2e.test.ts:15:5
await copilotClient.stop();
await openAiEndpoint.stop(anyTestFailed);
removeDisconnectedSessionEntries(copilotClient);
const stopErrors = await copilotClient.stop();
let proxyStopError: unknown;
try {
await openAiEndpoint.stop(anyTestFailed);
} catch (error) {
proxyStopError = error;
}
await rmDir("remove e2e test copilotHomeDir", copilotHomeDir);
await rmDir("remove e2e test homeDir", homeDir);
await rmDir("remove e2e test workDir", workDir);
if (stopErrors.length > 0) {
throw new AggregateError(stopErrors, "Copilot client cleanup failed");
}
if (proxyStopError) {
throw proxyStopError;
}
});

return harness;
}

function removeDisconnectedSessionEntries(client: CopilotClient): void {
// `CopilotSession.disconnect()` leaves its object in the client's private registry.
// The in-process client stop path aborts every registry entry, including these
// already-destroyed sessions. Remove only stale test entries before teardown.
const sessions = (
client as unknown as {
sessions: Map<string, { disconnected: boolean }>;
}
).sessions;
for (const [sessionId, session] of sessions) {
if (session.disconnected) {
sessions.delete(sessionId);
}
}
}

function getTrafficCapturePath(testContext: TestContext): string {
const testFilePath = testContext.task.file.filepath;
const suffix = ".test.ts";
Expand Down
Loading