Skip to content

Commit 9e21819

Browse files
committed
fix: improve port resolution logic with interval polling
1 parent c24d63a commit 9e21819

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/ipc/init.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,22 @@ async function waitHostBus(): Promise<number> {
2929
}
3030

3131
return new Promise((resolve) => {
32+
const interval = setInterval(async () => {
33+
const port = await read(file)
34+
if (port) {
35+
unwatch.then(unwatch => unwatch())
36+
clearInterval(interval)
37+
resolve(port)
38+
}
39+
}, 5000)
40+
3241
const unwatch = watch(
3342
file,
3443
async () => {
3544
const port = await read(file)
3645
if (port) {
3746
unwatch.then(unwatch => unwatch())
47+
clearInterval(interval)
3848
resolve(port)
3949
}
4050
},

0 commit comments

Comments
 (0)