You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the request-promise library to simplify the readability of a simple file download function. I came across an issue where the piped stream throws an error when it should already have been closed.
function causing errors function download(uri,dest){ return new Promise(function(resolve, reject){ let req = request(uri); progress(req) .on('error', function (err) { reject(err); }) .on('end', function () { resolve() }) .pipe(fs.createWriteStream(dest)); }); }
workaround by piping from the request object function download(uri,dest){ return new Promise(function(resolve, reject){ let req = request(uri); progress(req) .on('error', function (err) { reject(err); }) .on('end', function () { resolve() }); req.pipe(fs.createWriteStream(dest)); }); }
In my scenario I am downloading the file to a temporary location, and at some point after the download function resolves the file is deleted, causing an exception: Error: ENOENT: no such file or directory, open '/tmp/B1q5rRTOZ/ry_OPC6_Z' ^ throw er; // Unhandled stream error in pipe. internal/streams/legacy.js:59
The text was updated successfully, but these errors were encountered:
I am using the request-promise library to simplify the readability of a simple file download function. I came across an issue where the piped stream throws an error when it should already have been closed.
function causing errors
function download(uri,dest){ return new Promise(function(resolve, reject){ let req = request(uri); progress(req) .on('error', function (err) { reject(err); }) .on('end', function () { resolve() }) .pipe(fs.createWriteStream(dest)); }); }
workaround by piping from the request object
function download(uri,dest){ return new Promise(function(resolve, reject){ let req = request(uri); progress(req) .on('error', function (err) { reject(err); }) .on('end', function () { resolve() }); req.pipe(fs.createWriteStream(dest)); }); }
In my scenario I am downloading the file to a temporary location, and at some point after the download function resolves the file is deleted, causing an exception:
Error: ENOENT: no such file or directory, open '/tmp/B1q5rRTOZ/ry_OPC6_Z' ^ throw er; // Unhandled stream error in pipe. internal/streams/legacy.js:59
The text was updated successfully, but these errors were encountered: