feat(server): add function to wait for OpenCode port
This commit is contained in:
@@ -969,6 +969,22 @@ function setOpenCodePort(port) {
|
|||||||
lastOpenCodeError = null;
|
lastOpenCodeError = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function waitForOpenCodePort(timeoutMs = 15000) {
|
||||||
|
if (openCodePort !== null) {
|
||||||
|
return openCodePort;
|
||||||
|
}
|
||||||
|
|
||||||
|
const deadline = Date.now() + timeoutMs;
|
||||||
|
while (Date.now() < deadline) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||||
|
if (openCodePort !== null) {
|
||||||
|
return openCodePort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error('Timed out waiting for OpenCode port');
|
||||||
|
}
|
||||||
|
|
||||||
function getLoginShellPath() {
|
function getLoginShellPath() {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user