Skip to content

Commit

Permalink
doc: deprecate (doc-only) http abort related
Browse files Browse the repository at this point in the history
Refs: nodejs#36641
Refs: nodejs#36617 (comment)

Documentation-only deprecate `.aborted` property and `'abort'`, `'aborted'` event in `http`, and suggest using the corresponding Stream API instead.

Co-authored-by: Michaël Zasso <[email protected]>
  • Loading branch information
dr-js and targos committed Dec 29, 2020
1 parent 75afb6c commit 80ee6ee
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
24 changes: 24 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2699,6 +2699,27 @@ resolutions not in `node_modules`. This means there will not be deprecation
warnings for `"exports"` in dependencies. With `--pending-deprecation`, a
runtime warning results no matter where the `"exports"` usage occurs.

<a id="DEP0XXX"></a>
### DEP0XXX: `.aborted` property and `'abort'`, `'aborted'` event in `http`
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/36670
description: Documentation-only deprecation.
-->

Type: Documentation-only

Move to {Stream} API instead, as the [`http.ClientRequest`][],
[`http.ServerResponse`][], and [`http.IncomingMessage`][] are all stream-based.
Check `stream.destroyed` instead of the `.aborted` property, and listen for
`'close'` instead of `'abort'`, `'aborted'` event.

The `.aborted` property and `'abort'` event is only useful for detecting
`.abort()` calls. For closing a request early, use the Stream
`.destroy([error])` then check the `.destroyed` property and `'close'` event
should have the same effect.

[Legacy URL API]: url.md#url_legacy_url_api
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
Expand Down Expand Up @@ -2753,6 +2774,9 @@ runtime warning results no matter where the `"exports"` usage occurs.
[`fs.read()`]: fs.md#fs_fs_read_fd_buffer_offset_length_position_callback
[`fs.readSync()`]: fs.md#fs_fs_readsync_fd_buffer_offset_length_position
[`fs.stat()`]: fs.md#fs_fs_stat_path_options_callback
[`http.ClientRequest`]: #http_class_http_clientrequest
[`http.IncomingMessage`]: #http_class_http_incomingmessage
[`http.ServerResponse`]: #http_class_http_serverresponse
[`http.get()`]: http.md#http_http_get_options_callback
[`http.request()`]: http.md#http_http_request_options_callback
[`https.get()`]: https.md#https_https_get_options_callback
Expand Down
15 changes: 14 additions & 1 deletion doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,11 @@ body which has been transmitted are equal or not.
### Event: `'abort'`
<!-- YAML
added: v1.4.1
deprecated: REPLACEME
-->

> Stability: 0 - Deprecated. Listen for the `'close'` event instead.
Emitted when the request has been aborted by the client. This event is only
emitted on the first call to `abort()`.

Expand Down Expand Up @@ -553,7 +556,7 @@ added: v0.7.8
-->

Emitted when the underlying socket times out from inactivity. This only notifies
that the socket has been idle. The request must be aborted manually.
that the socket has been idle. The request must be destroyed manually.

See also: [`request.setTimeout()`][].

Expand Down Expand Up @@ -634,12 +637,15 @@ in the response to be dropped and the socket to be destroyed.
### `request.aborted`
<!-- YAML
added: v0.11.14
deprecated: REPLACEME
changes:
- version: v11.0.0
pr-url: https://github.com/nodejs/node/pull/20230
description: The `aborted` property is no longer a timestamp number.
-->

> Stability: 0 - Deprecated. Check [`request.destroyed`][] instead.
* {boolean}

The `request.aborted` property will be `true` if the request has
Expand Down Expand Up @@ -1923,8 +1929,11 @@ status, headers and data.
### Event: `'aborted'`
<!-- YAML
added: v0.3.8
deprecated: REPLACEME
-->

> Stability: 0 - Deprecated. Listen for `'close'` event instead.
Emitted when the request has been aborted.

### Event: `'close'`
Expand All @@ -1937,8 +1946,11 @@ Indicates that the underlying connection was closed.
### `message.aborted`
<!-- YAML
added: v10.1.0
deprecated: REPLACEME
-->

> Stability: 0 - Deprecated. Check `message.destroyed` from {stream.Readable}.
* {boolean}

The `message.aborted` property will be `true` if the request has
Expand Down Expand Up @@ -2733,6 +2745,7 @@ try {
[`removeHeader(name)`]: #http_request_removeheader_name
[`request.end()`]: #http_request_end_data_encoding_callback
[`request.destroy()`]: #http_request_destroy_error
[`request.destroyed`]: #http_request_destroyed
[`request.flushHeaders()`]: #http_request_flushheaders
[`request.getHeader()`]: #http_request_getheader_name
[`request.setHeader()`]: #http_request_setheader_name_value
Expand Down

0 comments on commit 80ee6ee

Please sign in to comment.