fix: Ensure stream is fully buffered.

Needs a more permanent fix for Very Large Streams.
This commit is contained in:
Ruben Verborgh 2020-09-03 14:32:42 +02:00
parent 9fb54b8958
commit 986461f6fe

View File

@ -151,10 +151,11 @@ export class InMemoryResourceStore implements ResourceStore {
// Note: when converting to a complete ResourceStore and using readable-stream // Note: when converting to a complete ResourceStore and using readable-stream
// object mode should be set correctly here (now fixed due to Node 10) // object mode should be set correctly here (now fixed due to Node 10)
const source = this.store[path]; const source = this.store[path];
const streamInternal = new PassThrough({ writableObjectMode: true, readableObjectMode: true }); const objectMode = { writableObjectMode: true, readableObjectMode: true };
const streamOutput = new PassThrough({ writableObjectMode: true, readableObjectMode: true }); const streamOutput = new PassThrough(objectMode);
source.data.pipe(streamInternal); const streamInternal = new PassThrough({ ...objectMode, highWaterMark: Number.MAX_SAFE_INTEGER });
source.data.pipe(streamOutput); source.data.pipe(streamOutput);
source.data.pipe(streamInternal);
source.data = streamInternal; source.data = streamInternal;