feat(server): add function to wait for OpenCode port

This commit is contained in:
Bohdan Triapitsyn
2026-01-13 19:44:13 +02:00
parent abc8e89367
commit fbb058ed97
+16
View File
@@ -969,6 +969,22 @@ function setOpenCodePort(port) {
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() {
if (process.platform === 'win32') {
return null;