Skip to content

Commit bc927d6

Browse files
dr-jstargosTrottronagaduh95
committed
doc: deprecate (doc-only) http abort related
Refs: #36641 Refs: #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 <targos@protonmail.com> Co-authored-by: Rich Trott <rtrott@gmail.com> Co-authored-by: Robert Nagy <ronagy@icloud.com> Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent fc3f1c3 commit bc927d6

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

doc/api/deprecations.md

+26
Original file line numberDiff line numberDiff line change
@@ -2711,6 +2711,28 @@ Type: Documentation-only.
27112711

27122712
Prefer [`message.socket`][] over [`message.connection`][].
27132713

2714+
### DEP0XXX: `.aborted` property and `'abort'`, `'aborted'` event in `http`
2715+
<!-- YAML
2716+
changes:
2717+
- version: REPLACEME
2718+
pr-url: https://github.com/nodejs/node/pull/36670
2719+
description: Documentation-only deprecation.
2720+
-->
2721+
2722+
Type: Documentation-only
2723+
2724+
Move to {Stream} API instead, as the [`http.ClientRequest`][],
2725+
[`http.ServerResponse`][], and [`http.IncomingMessage`][] are all stream-based.
2726+
Check `stream.destroyed` instead of the `.aborted` property, and listen for
2727+
`'close'` instead of `'abort'`, `'aborted'` event.
2728+
2729+
The `.aborted` property and `'abort'` event are only useful for detecting
2730+
`.abort()` calls. For closing a request early, use the Stream
2731+
`.destroy([error])` then check the `.destroyed` property and `'close'` event
2732+
should have the same effect. The receiving end should also check the
2733+
[`readable.readableEnded`][] value on [`http.IncomingMessage`][] to get whether
2734+
it was an aborted or graceful destroy.
2735+
27142736
[Legacy URL API]: url.md#url_legacy_url_api
27152737
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
27162738
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -2765,6 +2787,9 @@ Prefer [`message.socket`][] over [`message.connection`][].
27652787
[`fs.read()`]: fs.md#fs_fs_read_fd_buffer_offset_length_position_callback
27662788
[`fs.readSync()`]: fs.md#fs_fs_readsync_fd_buffer_offset_length_position
27672789
[`fs.stat()`]: fs.md#fs_fs_stat_path_options_callback
2790+
[`http.ClientRequest`]: #http_class_http_clientrequest
2791+
[`http.IncomingMessage`]: #http_class_http_incomingmessage
2792+
[`http.ServerResponse`]: #http_class_http_serverresponse
27682793
[`http.get()`]: http.md#http_http_get_options_callback
27692794
[`http.request()`]: http.md#http_http_request_options_callback
27702795
[`https.get()`]: https.md#https_https_get_options_callback
@@ -2777,6 +2802,7 @@ Prefer [`message.socket`][] over [`message.connection`][].
27772802
[`process.env`]: process.md#process_process_env
27782803
[`process.mainModule`]: process.md#process_process_mainmodule
27792804
[`punycode`]: punycode.md
2805+
[`readable.readableEnded`]: stream.md#stream_readable_readableended
27802806
[`request.abort()`]: http.md#http_request_abort
27812807
[`request.connection`]: http.md#http_request_connection
27822808
[`request.destroy()`]: http.md#http_request_destroy_error

doc/api/http.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,11 @@ body which has been transmitted are equal or not.
405405
### Event: `'abort'`
406406
<!-- YAML
407407
added: v1.4.1
408+
deprecated: REPLACEME
408409
-->
409410

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

@@ -562,7 +565,7 @@ added: v0.7.8
562565
-->
563566

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

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

@@ -643,12 +646,15 @@ in the response to be dropped and the socket to be destroyed.
643646
### `request.aborted`
644647
<!-- YAML
645648
added: v0.11.14
649+
deprecated: REPLACEME
646650
changes:
647651
- version: v11.0.0
648652
pr-url: https://github.com/nodejs/node/pull/20230
649653
description: The `aborted` property is no longer a timestamp number.
650654
-->
651655

656+
> Stability: 0 - Deprecated. Check [`request.destroyed`][] instead.
657+
652658
* {boolean}
653659

654660
The `request.aborted` property will be `true` if the request has
@@ -1950,8 +1956,11 @@ may be reused multiple times in case of keep-alive.
19501956
### Event: `'aborted'`
19511957
<!-- YAML
19521958
added: v0.3.8
1959+
deprecated: REPLACEME
19531960
-->
19541961

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

19571966
### Event: `'close'`
@@ -1964,8 +1973,11 @@ Indicates that the underlying connection was closed.
19641973
### `message.aborted`
19651974
<!-- YAML
19661975
added: v10.1.0
1976+
deprecated: REPLACEME
19671977
-->
19681978

1979+
> Stability: 0 - Deprecated. Check `message.destroyed` from {stream.Readable}.
1980+
19691981
* {boolean}
19701982

19711983
The `message.aborted` property will be `true` if the request has
@@ -2771,6 +2783,7 @@ try {
27712783
[`removeHeader(name)`]: #http_request_removeheader_name
27722784
[`request.end()`]: #http_request_end_data_encoding_callback
27732785
[`request.destroy()`]: #http_request_destroy_error
2786+
[`request.destroyed`]: #http_request_destroyed
27742787
[`request.flushHeaders()`]: #http_request_flushheaders
27752788
[`request.getHeader()`]: #http_request_getheader_name
27762789
[`request.setHeader()`]: #http_request_setheader_name_value

0 commit comments

Comments
 (0)