From 049fda37ac873bb51eaa73d1f1af06cf09ebe31e Mon Sep 17 00:00:00 2001 From: Bryce Gibson Date: Mon, 3 Apr 2023 09:10:23 +1000 Subject: [PATCH] WIP: ensure the stream is consumed before end/close are emitted. --- src/compiler.ts | 2 +- src/fs/bundle.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler.ts b/src/compiler.ts index 65c96cb..64096a4 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -294,7 +294,7 @@ export class NexeCompiler { return binary } const launchCode = this.code() - const vfsStream = await this.bundle.toStream() + const vfsStream = this.bundle.toStream() let vfsSize = 0 const vfsSum = new Transform({ transform(chunk, _enc, cb) { diff --git a/src/fs/bundle.ts b/src/fs/bundle.ts index f206b6e..04c3be8 100644 --- a/src/fs/bundle.ts +++ b/src/fs/bundle.ts @@ -41,8 +41,8 @@ export class Bundle { } } - public async toStream(): Promise { - await this.zip.finalize() + public toStream(): Readable { + setTimeout(() => this.zip.finalize()) return this.zip } }