New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using CancelableRequest.cancel with cache causes UncaughtException #1925
Comments
I'm encountering the same thing, but I'm not trying to cancel the request, just trying to read the response body. |
I think I have the same issue when the request timeout is triggered import got from "got"; // version 12.0.3
// 3.5Mb so times out
const url =
"https://www.interieur.gouv.fr/avotreservice/elections/telechargements/PR2017/resultatsT2/032/002/002com.xml";
got(url, {
cache: new Map(),
timeout: {
request: 500,
},
})
.then((res) => {
if (res.statusCode !== 200) {
console.error(
`${res.statusCode} - ${res.statusMessage} - fetching ${url}`
);
}
return res.body.slice(0, 100);
})
.catch((err) => {
console.log("ooooh", err);
});
|
@aubergene @langri-sha - just FYI that the next version being released in October 22 will have a fix around this. jaredwray/cacheable-request#206 |
@jaredwray thank you |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
In the above code, when I call CancelableRequest.cancel(
r.cancel()
) with cache in options, ECONNRESET exception is throwed byget-stream
package(in addition to CancelError(handled)), which is unhandled even if I put.catch
to the returned CancelableRequest.When I remove
cache
options, the program only throws CancelError.According to stacktrace, the exception is throwed in rejectPromise function in
get-stream
package, called by error callback of pump.https://github.com/sindresorhus/get-stream/blob/main/index.js#L36
inputStream
comes from cacheable-request.https://github.com/lukechilds/cacheable-request/blob/master/src/index.js#L106
Actual behavior
aborted
(ECONNRESET) exception is throwed, and it is not handled.Expected behavior
Cancellation only causes
CancelError
, not withaborted
(ECONNRESET) exception.Code to reproduce
Runkit: https://runkit.com/femshima/got-cancel-with-cache
(For more details, please see https://github.com/femshima/got-cancel-cache)
Checklist
I have read the documentation.
I have tried my code with the latest version of Node.js and Got.
The text was updated successfully, but these errors were encountered: