Skip to content

Commit af281a9

Browse files
authored
fix(mcp): clear timeout timer in bootstrapOneWorkspace to prevent leak (#88)
1 parent 7fdb87a commit af281a9

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

packages/mcp/src/transports.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ async function bootstrapOneWorkspace(
6969
};
7070

7171
try {
72-
const timeout = new Promise<never>((_, reject) =>
73-
setTimeout(() => reject(new Error(`Bootstrap timed out after ${timeoutMs}ms`)), timeoutMs),
74-
);
75-
return await Promise.race([doBootstrap(), timeout]);
72+
let timer: ReturnType<typeof setTimeout>;
73+
const timeout = new Promise<never>((_, reject) => {
74+
timer = setTimeout(() => reject(new Error(`Bootstrap timed out after ${timeoutMs}ms`)), timeoutMs);
75+
});
76+
const result = await Promise.race([doBootstrap(), timeout]);
77+
clearTimeout(timer!);
78+
return result;
7679
} catch (err) {
7780
console.error(
7881
`[bootstrap] Failed to bootstrap workspace ${ws.workspace_id}: ${err instanceof Error ? err.message : String(err)}`,

0 commit comments

Comments
 (0)