Skip to content

Commit 8462b70

Browse files
committed
fix(code-server): enhance port resolution logic
1 parent 908f9fd commit 8462b70

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎plugins/code-server/src/node/supervisor.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,15 @@ export class CodeServerSupervisor {
299299
return this.status()
300300
}
301301

302-
/** Resolve the port to launch on: 0 for tunnels/dynamic, a forced port, or a free one. */
302+
/**
303+
* Resolve the port to launch on: 0 for tunnels/dynamic launches, otherwise a
304+
* free port starting from the forced port (if any) or the default -
305+
* verified free before it's ever handed to the editor binary's `--port`.
306+
*/
303307
private async resolveInitialPort(isLocal: boolean): Promise<number> {
304-
if (!isLocal)
305-
return 0
306-
if (this.forcedPort !== undefined && this.forcedPort !== 0)
307-
return this.forcedPort
308-
if (this.forcedPort === 0)
308+
if (!isLocal || this.forcedPort === 0)
309309
return 0
310-
return getPort({ host: '127.0.0.1', port: DEFAULT_CODE_SERVER_PORT })
310+
return getPort({ host: '127.0.0.1', port: this.forcedPort ?? DEFAULT_CODE_SERVER_PORT })
311311
}
312312

313313
/** The child's environment: inherited env, caller overrides, then profile shaping. */

0 commit comments

Comments
 (0)