fix: need to refactor verification stream logic further and check if the stream is done but wasm isn't

This commit is contained in:
Derrick Hammer 2023-06-24 04:28:08 -04:00
parent 50a7c80358
commit 051f4b2da7
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 10 additions and 2 deletions

View File

@ -83,16 +83,24 @@ export async function getVerifiableStream(
if (chunk.done || wasmDone) { if (chunk.done || wasmDone) {
if (wasmDone) { if (wasmDone) {
if (result) { if (result) {
controller.enqueue(chunk.value);
done(controller); done(controller);
} else { } else {
controller.error(getWasmProperty(wasmId, "error")); controller.error(getWasmProperty(wasmId, "error"));
exit();
} }
} else { } else {
if (!wasmDone) {
controller.error("stream is ended but verification not complete");
exit();
return;
}
controller.enqueue(chunk.value);
done(controller); done(controller);
} }
} } else {
controller.enqueue(chunk.value); controller.enqueue(chunk.value);
}
}, },
async cancel(reason: any) { async cancel(reason: any) {
await reader.cancel(reason); await reader.cancel(reason);