Skip to content

Commit 81b5d7b

Browse files
committed
fix: cleanup server on cancellation
1 parent 3b564ba commit 81b5d7b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/kernels/deepnote/deepnoteServerStarter.node.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,16 @@ export class DeepnoteServerStarter implements IDeepnoteServerStarter {
151151
const serverInfo = { url, port };
152152
this.serverInfos.set(fileKey, serverInfo);
153153

154-
const serverReady = await this.waitForServer(serverInfo, 30000, token);
155-
if (!serverReady) {
154+
try {
155+
const serverReady = await this.waitForServer(serverInfo, 30000, token);
156+
if (!serverReady) {
157+
await this.stopServerImpl(deepnoteFileUri);
158+
throw new Error('Deepnote server failed to start within timeout period');
159+
}
160+
} catch (error) {
161+
// Clean up leaked server before rethrowing
156162
await this.stopServerImpl(deepnoteFileUri);
157-
throw new Error('Deepnote server failed to start within timeout period');
163+
throw error;
158164
}
159165

160166
logger.info(`Deepnote server started successfully at ${url} for ${fileKey}`);

0 commit comments

Comments
 (0)