Skip to content

Commit

Permalink
Simplify RPC watchWorker (#3394)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 13, 2022
1 parent 6e018ea commit 3151648
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions packages/core/rpc/BaseRpcDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,13 @@ export async function watchWorker(
rpcDriverClassName: string,
) {
// after first ping succeeds, apply wait for timeout
return new Promise((_resolve, reject) => {
function delay() {
setTimeout(async () => {
try {
await worker.call('ping', [], {
timeout: pingTime * 2,
rpcDriverClassName,
})
delay()
} catch (e) {
reject(e)
}
}, pingTime)
}
delay()
})
while (true) {
await worker.call('ping', [], {
timeout: pingTime * 2,
rpcDriverClassName,
})
await new Promise(resolve => setTimeout(resolve, pingTime))
}
}

function detectHardwareConcurrency() {
Expand Down

0 comments on commit 3151648

Please sign in to comment.