Skip to content

Commit 0b2ba44

Browse files
zbjornsonRafaelGSS
authored andcommitted
doc: clarify http error events after calling destroy()
PR-URL: #46903 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 9ecf2a4 commit 0b2ba44

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

doc/api/http.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -3644,7 +3644,7 @@ the following events will be emitted in the following order:
36443644
* (connection closed here)
36453645
* `'aborted'` on the `res` object
36463646
* `'error'` on the `res` object with an error with message
3647-
`'Error: aborted'` and code `'ECONNRESET'`.
3647+
`'Error: aborted'` and code `'ECONNRESET'`
36483648
* `'close'`
36493649
* `'close'` on the `res` object
36503650

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)