Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: clarify http error events after calling destroy() #46903

Merged
merged 1 commit into from Mar 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions doc/api/http.md
Expand Up @@ -3652,7 +3652,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 @@ -3661,7 +3661,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 @@ -3670,7 +3670,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 @@ -3681,8 +3681,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 @@ -3720,9 +3720,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

Suggested change
request. Specifically, the `'error'` event will be emitted with an error with
request itself. Specifically, the `'error'` event will be emitted with an error with

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was going for brevity. "Itself" doesn't seem to add clarity. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think its a necessary change to this pr, Id leave it as it was previously

the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`
Comment on lines +3725 to +3726
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
request. Specifically, the `'error'` event will be emitted with an error with
the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`
request. Specifically, the `'error'` event will be emitted with the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parallels the wording in the bullet points above and makes it clear that the argument is an Error and not a string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds a bit reduntant to me, feel free to ignore

and the `cause`, if one was provided.

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

Expand Down