( host: string = DEFAULT_SERVER_HOST, preferred: number = DEFAULT_SERVER_PORT, )
| 132 | * the server's own "port busy ⇒ +1" bind retry. |
| 133 | */ |
| 134 | export async function resolveDaemonPort( |
| 135 | host: string = DEFAULT_SERVER_HOST, |
| 136 | preferred: number = DEFAULT_SERVER_PORT, |
| 137 | ): Promise<number> { |
| 138 | for ( |
| 139 | let candidate = preferred; |
| 140 | candidate < preferred + DAEMON_PORT_SCAN_LIMIT && candidate <= 65535; |
| 141 | candidate++ |
| 142 | ) { |
| 143 | if (await canBind(host, candidate)) return candidate; |
| 144 | } |
| 145 | return getFreePort(host); |
| 146 | } |
| 147 | |
| 148 | interface NodeSeaModule { |
| 149 | isSea(): boolean; |
no test coverage detected