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
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
function download (url, file, callback) {
http.get(url, function (res) {
res.pipe(file, {end: 'false});
res.on('end', function () {
file.end();
callback(file.path);
});
}).on('error', function (err) {
offline(err);
});
}
If internet is shut down before the http.get, it trigger the error with ENETUNREACH as err, and I can handle it. But if I shut down internet while the file is being downloaded, the connection just hang until it is back on (and usually crash when so).
Is there a way to detect that internet is shut down in the middle of the download?
The text was updated successfully, but these errors were encountered:
TCP will timeout eventually and the next time you tried to write or read you would get an ECONNRESET or EPIPE -- but if you want to be more aggressive you can use req.setTimeout or res.setTimeout and if data hasn't traversed in that time frame it will fire a timeout event.
This kind of question though is more suited for irc or the mailing list.
function download (url, file, callback) {
http.get(url, function (res) {
res.pipe(file, {end: 'false});
res.on('end', function () {
file.end();
callback(file.path);
});
}).on('error', function (err) {
offline(err);
});
}
If internet is shut down before the http.get, it trigger the error with ENETUNREACH as err, and I can handle it. But if I shut down internet while the file is being downloaded, the connection just hang until it is back on (and usually crash when so).
Is there a way to detect that internet is shut down in the middle of the download?
The text was updated successfully, but these errors were encountered: