diff --git a/packages/compute-protocol/package.json b/packages/compute-protocol/package.json index 826de79..3ced99c 100644 --- a/packages/compute-protocol/package.json +++ b/packages/compute-protocol/package.json @@ -1,7 +1,7 @@ { "name": "@blink-sdk/compute-protocol", "description": "The compute protocol for the Blink SDK.", - "version": "0.0.6", + "version": "0.0.7", "type": "module", "keywords": [ "blink", diff --git a/packages/compute-protocol/src/server.ts b/packages/compute-protocol/src/server.ts index f302913..c42a48a 100644 --- a/packages/compute-protocol/src/server.ts +++ b/packages/compute-protocol/src/server.ts @@ -640,11 +640,16 @@ export class Server { }, payload.timeout_ms); } - const end = () => { + const end = async () => { if (ended) { return; } ended = true; + // This is janky, but it seems like there's a single tick + // between when output is available _sometimes_. If we don't + // do this, semi-occasionally the plain output will be incorrect. + // TODO: ensure all process output is written before this function is called instead of a sleep + await new Promise((resolve) => setTimeout(resolve, 50)); if (onOutput) { onOutput.dispose(); } @@ -703,12 +708,7 @@ export class Server { } }); onExit = process.onExit(() => { - // This is janky, but it seems like there's a single tick - // between when output is available _sometimes_. If we don't - // do this, semi-occasionally the plain output will be incorrect. - setTimeout(() => { - end(); - }, 10); + end(); }); signal.addEventListener("abort", () => {