From 89d1b9e644eec384d634a25d4cddb6d229d266ac Mon Sep 17 00:00:00 2001 From: C-3PO Date: Thu, 5 Jul 2018 21:17:07 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Found=20error=20why=20.read()=20?= =?UTF-8?q?returns=20null;=20need=20to=20wait=20for=20readable=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cdn/funcs/saveResponse.ts | 2 +- src/ssn/streams/getFileFromDisks.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cdn/funcs/saveResponse.ts b/src/cdn/funcs/saveResponse.ts index 2509d77..896c80b 100644 --- a/src/cdn/funcs/saveResponse.ts +++ b/src/cdn/funcs/saveResponse.ts @@ -58,7 +58,7 @@ export default function saveResponse( //TODO: need to automatically delete file once it is no longer used //TODO: need to provide methods to seek through file return resolve(tempFileName); - //const stream = fs.createReadStream(tempFileName, { encoding: 'binary' }); //TODO: we may need to remove encoding since mentioning encoding automatically switches to string format + //const stream = fs.createReadStream(tempFileName); //return resolve(stream); }); } diff --git a/src/ssn/streams/getFileFromDisks.ts b/src/ssn/streams/getFileFromDisks.ts index 0d1f3ae..4b87b50 100644 --- a/src/ssn/streams/getFileFromDisks.ts +++ b/src/ssn/streams/getFileFromDisks.ts @@ -28,6 +28,7 @@ export default function getFileFromDisks(disks: string[], { diskStart, offset, s if (chunk === null) { curDiskIndex += 1; curDisk = getStream(disks, curDiskIndex, 0); + //await new Promise((resolve) => { curDisk.on('readable', () => { resolve(); }); }); return curDisk.read(num); } else { return chunk;