Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use
aborted
property on http request (#1134)
I had some difficulty with this code: httpRequest.on('timeout', function () { trackFailure('timeout') httpRequest.abort() }) httpRequest.on('error', function (err) { // Count error if request wasn't aborted due to timeout if (!httpRequest.aborted) { trackFailure(err) } callback(err) } When `nock` was not in use, `trackFailure()` would be called once on timeout. With `nock` enabled, `trackFailure()` would be called twice because `httpRequest.aborted` would be undefined. This change creates and uses the `aborted` property in the same fashion as the system `http` module.
- Loading branch information
Showing
1 changed file
with
11 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters