Skip to content

Commit 9a035e1

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 bcb9e9e commit 9a035e1

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

doc/api/deprecations.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,28 @@ Type: Documentation-only (supports [`--pending-deprecation`][])
28262826
The remapping of specifiers ending in `"/"` like `import 'pkg/x/'` is deprecated
28272827
for package `"exports"` and `"imports"` pattern resolutions.
28282828

2829+
### DEP0XXX: `.aborted` property and `'abort'`, `'aborted'` event in `http`
2830+
<!-- YAML
2831+
changes:
2832+
- version: REPLACEME
2833+
pr-url: https://github.com/nodejs/node/pull/36670
2834+
description: Documentation-only deprecation.
2835+
-->
2836+
2837+
Type: Documentation-only
2838+
2839+
Move to {Stream} API instead, as the [`http.ClientRequest`][],
2840+
[`http.ServerResponse`][], and [`http.IncomingMessage`][] are all stream-based.
2841+
Check `stream.destroyed` instead of the `.aborted` property, and listen for
2842+
`'close'` instead of `'abort'`, `'aborted'` event.
2843+
2844+
The `.aborted` property and `'abort'` event are only useful for detecting
2845+
`.abort()` calls. For closing a request early, use the Stream
2846+
`.destroy([error])` then check the `.destroyed` property and `'close'` event
2847+
should have the same effect. The receiving end should also check the
2848+
[`readable.readableEnded`][] value on [`http.IncomingMessage`][] to get whether
2849+
it was an aborted or graceful destroy.
2850+
28292851
[Legacy URL API]: url.md#url_legacy_url_api
28302852
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
28312853
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -2883,6 +2905,9 @@ for package `"exports"` and `"imports"` pattern resolutions.
28832905
[`fs.read()`]: fs.md#fs_fs_read_fd_buffer_offset_length_position_callback
28842906
[`fs.readSync()`]: fs.md#fs_fs_readsync_fd_buffer_offset_length_position
28852907
[`fs.stat()`]: fs.md#fs_fs_stat_path_options_callback
2908+
[`http.ClientRequest`]: #http_class_http_clientrequest
2909+
[`http.IncomingMessage`]: #http_class_http_incomingmessage
2910+
[`http.ServerResponse`]: #http_class_http_serverresponse
28862911
[`http.get()`]: http.md#http_http_get_options_callback
28872912
[`http.request()`]: http.md#http_http_request_options_callback
28882913
[`https.get()`]: https.md#https_https_get_options_callback
@@ -2895,6 +2920,7 @@ for package `"exports"` and `"imports"` pattern resolutions.
28952920
[`process.env`]: process.md#process_process_env
28962921
[`process.mainModule`]: process.md#process_process_mainmodule
28972922
[`punycode`]: punycode.md
2923+
[`readable.readableEnded`]: stream.md#stream_readable_readableended
28982924
[`request.abort()`]: http.md#http_request_abort
28992925
[`request.connection`]: http.md#http_request_connection
29002926
[`request.destroy()`]: http.md#http_request_destroy_error

doc/api/http.md

Lines changed: 14 additions & 1 deletion
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
@@ -1984,8 +1990,11 @@ may be reused multiple times in case of keep-alive.
19841990
### Event: `'aborted'`
19851991
<!-- YAML
19861992
added: v0.3.8
1993+
deprecated: REPLACEME
19871994
-->
19881995

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

19912000
### Event: `'close'`
@@ -1998,8 +2007,11 @@ Indicates that the underlying connection was closed.
19982007
### `message.aborted`
19992008
<!-- YAML
20002009
added: v10.1.0
2010+
deprecated: REPLACEME
20012011
-->
20022012

2013+
> Stability: 0 - Deprecated. Check `message.destroyed` from {stream.Readable}.
2014+
20032015
* {boolean}
20042016

20052017
The `message.aborted` property will be `true` if the request has
@@ -3231,6 +3243,7 @@ try {
32313243
[`outgoingMessage.socket`]: #http_outgoingmessage_socket
32323244
[`removeHeader(name)`]: #http_request_removeheader_name
32333245
[`request.destroy()`]: #http_request_destroy_error
3246+
[`request.destroyed`]: #http_request_destroyed
32343247
[`request.end()`]: #http_request_end_data_encoding_callback
32353248
[`request.flushHeaders()`]: #http_request_flushheaders
32363249
[`request.getHeader()`]: #http_request_getheader_name

0 commit comments

Comments
 (0)