Hello,I'm currently building a NodeJS App, and I need to move data from one stream (readable) to another one (writable).I have made an extremely simplified example below, I don't understand why the promise make the app crash. If I catch the error (using readStream.on('error', () ...) the pipeline's callback is never called.How would you handle this?const { pipeline } = require('stream'); const { createReadStream, createWriteStream } = require('fs'); (async () => { const readStream = createReadStream('file not existing'); // if this promise is removed, the error will be catched by the pipeline await new Promise(r => setTimeout(r, 1000)); const writeStream = createWriteStream('dist'); pipeline(readStream, writeStream, (err) => { console.log('Error ?', err); }); })(); Thanks.
Submitted October 14, 2019 at 08:41PM by idontknownwhatodo
No comments:
Post a Comment