Skip to content

Commit

Permalink
doc: clarify http error events after calling destroy()
Browse files Browse the repository at this point in the history
PR-URL: #46903
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
zbjornson authored and RafaelGSS committed Apr 7, 2023
1 parent 9ecf2a4 commit 0b2ba44
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -3644,7 +3644,7 @@ the following events will be emitted in the following order:
* (connection closed here)
* `'aborted'` on the `res` object
* `'error'` on the `res` object with an error with message
`'Error: aborted'` and code `'ECONNRESET'`.
`'Error: aborted'` and code `'ECONNRESET'`
* `'close'`
* `'close'` on the `res` object

Expand All @@ -3653,7 +3653,7 @@ events will be emitted in the following order:

* (`req.destroy()` called here)
* `'error'` with an error with message `'Error: socket hang up'` and code
`'ECONNRESET'`
`'ECONNRESET'`, or the error with which `req.destroy()` was called
* `'close'`

If `req.destroy()` is called before the connection succeeds, the following
Expand All @@ -3662,7 +3662,7 @@ events will be emitted in the following order:
* `'socket'`
* (`req.destroy()` called here)
* `'error'` with an error with message `'Error: socket hang up'` and code
`'ECONNRESET'`
`'ECONNRESET'`, or the error with which `req.destroy()` was called
* `'close'`

If `req.destroy()` is called after the response is received, the following
Expand All @@ -3673,8 +3673,8 @@ events will be emitted in the following order:
* `'data'` any number of times, on the `res` object
* (`req.destroy()` called here)
* `'aborted'` on the `res` object
* `'error'` on the `res` object with an error with message
`'Error: aborted'` and code `'ECONNRESET'`.
* `'error'` on the `res` object with an error with message `'Error: aborted'`
and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
* `'close'`
* `'close'` on the `res` object

Expand Down Expand Up @@ -3712,9 +3712,11 @@ events will be emitted in the following order:
Setting the `timeout` option or using the `setTimeout()` function will
not abort the request or do anything besides add a `'timeout'` event.

Passing an `AbortSignal` and then calling `abort` on the corresponding
Passing an `AbortSignal` and then calling `abort()` on the corresponding
`AbortController` will behave the same way as calling `.destroy()` on the
request itself.
request. Specifically, the `'error'` event will be emitted with an error with
the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`
and the `cause`, if one was provided.

## `http.validateHeaderName(name[, label])`

Expand Down

0 comments on commit 0b2ba44

Please sign in to comment.