Skip to content

Commit 9b69472

Browse files
authored
fix: always sleep before end logic in handleProcessWait (#75)
1 parent bbfdadc commit 9b69472

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

packages/compute-protocol/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@blink-sdk/compute-protocol",
33
"description": "The compute protocol for the Blink SDK.",
4-
"version": "0.0.6",
4+
"version": "0.0.7",
55
"type": "module",
66
"keywords": [
77
"blink",

packages/compute-protocol/src/server.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,16 @@ export class Server {
640640
}, payload.timeout_ms);
641641
}
642642

643-
const end = () => {
643+
const end = async () => {
644644
if (ended) {
645645
return;
646646
}
647647
ended = true;
648+
// This is janky, but it seems like there's a single tick
649+
// between when output is available _sometimes_. If we don't
650+
// do this, semi-occasionally the plain output will be incorrect.
651+
// TODO: ensure all process output is written before this function is called instead of a sleep
652+
await new Promise((resolve) => setTimeout(resolve, 50));
648653
if (onOutput) {
649654
onOutput.dispose();
650655
}
@@ -703,12 +708,7 @@ export class Server {
703708
}
704709
});
705710
onExit = process.onExit(() => {
706-
// This is janky, but it seems like there's a single tick
707-
// between when output is available _sometimes_. If we don't
708-
// do this, semi-occasionally the plain output will be incorrect.
709-
setTimeout(() => {
710-
end();
711-
}, 10);
711+
end();
712712
});
713713

714714
signal.addEventListener("abort", () => {

0 commit comments

Comments
 (0)