Skip to content

Commit

Permalink
Update a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Nov 23, 2019
1 parent d0f2dfd commit 3acdb69
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/request-as-event-emitter.ts
Expand Up @@ -143,7 +143,6 @@ export default (options: NormalizedOptions) => {

const handleRequest = async (request: http.ClientRequest): Promise<void> => {
// `request.aborted` is a boolean since v11.0.0: https://github.com/nodejs/node/commit/4b00c4fafaa2ae8c41c1f78823c0feb810ae4723#diff-e3bc37430eb078ccbafe3aa3b570c91a
// We need to allow `TimedOutTimeoutError` here, because it `stream.pipeline(…)` aborts it automatically.
const isAborted = () => typeof request.aborted === 'number' || (request.aborted as unknown as boolean) === true;

currentRequest = request;
Expand All @@ -162,6 +161,7 @@ export default (options: NormalizedOptions) => {

const attachErrorHandler = () => {
request.once('error', error => {
// We need to allow `TimedOutTimeoutError` here, because `stream.pipeline(…)` aborts the request automatically.
if (isAborted() && !(error instanceof TimedOutTimeoutError)) {
return;
}
Expand Down

0 comments on commit 3acdb69

Please sign in to comment.