Skip to content

Commit f0ade70

Browse files
authored
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 9374700 commit f0ade70

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

doc/api/http.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,7 +3654,7 @@ the following events will be emitted in the following order:
36543654
* (connection closed here)
36553655
* `'aborted'` on the `res` object
36563656
* `'error'` on the `res` object with an error with message
3657-
`'Error: aborted'` and code `'ECONNRESET'`.
3657+
`'Error: aborted'` and code `'ECONNRESET'`
36583658
* `'close'`
36593659
* `'close'` on the `res` object
36603660

@@ -3663,7 +3663,7 @@ events will be emitted in the following order:
36633663

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

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

36783678
If `req.destroy()` is called after the response is received, the following
@@ -3683,8 +3683,8 @@ events will be emitted in the following order:
36833683
* `'data'` any number of times, on the `res` object
36843684
* (`req.destroy()` called here)
36853685
* `'aborted'` on the `res` object
3686-
* `'error'` on the `res` object with an error with message
3687-
`'Error: aborted'` and code `'ECONNRESET'`.
3686+
* `'error'` on the `res` object with an error with message `'Error: aborted'`
3687+
and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
36883688
* `'close'`
36893689
* `'close'` on the `res` object
36903690

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

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

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

0 commit comments

Comments
 (0)