Skip to content

Commit

Permalink
Remove request error handler after response is downloaded
Browse files Browse the repository at this point in the history
Affects only Promises
  • Loading branch information
szmarczak committed Jul 4, 2020
1 parent 4845ffd commit e1afe82
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/as-promise/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export default function asPromise<T>(options: NormalizedOptions): CancelableRequ
return;
}

// There should be no error when the response has been downloaded.
// If there is, an uncaught exception error will be thrown.
request.off('error', onError);

// Parse body
const contentEncoding = (response.headers['content-encoding'] ?? '').toLowerCase();
const isCompressed = ['gzip', 'deflate', 'br'].includes(contentEncoding);
Expand Down

0 comments on commit e1afe82

Please sign in to comment.