Skip to content

Commit 4b30112

Browse files
committed
Don't unnecessarily recreate existing terminal servers
1 parent 3777e6d commit 4b30112

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/interceptors/terminal/existing-terminal-interceptor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ export class ExistingTerminalInterceptor implements Interceptor {
2424
}
2525

2626
async activate(proxyPort: number): Promise<{ port: number }> {
27+
if (this.servers[proxyPort]) {
28+
return { port: this.servers[proxyPort].port };
29+
}
30+
2731
const server = getLocal();
28-
await server.start();
32+
await server.start({ startPort: proxyPort + 1, endPort: 65535 });
2933

3034
const envVars = getTerminalEnvVars(proxyPort, this.config.https, 'runtime-inherit');
3135
const setupScript = getShellScript(envVars);
32-
server.get('/setup').thenReply(200, setupScript, { "content-type": "text/x-shellscript" })
36+
server.get('/setup').thenReply(200, setupScript, { "content-type": "text/x-shellscript" });
3337

3438
this.servers[proxyPort] = server;
3539

0 commit comments

Comments
 (0)