Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9fec6fd

Browse files
dr-jstargosTrottronagaduh95
committedMar 4, 2021
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 3b2863d commit 9fec6fd

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
@@ -2767,6 +2767,28 @@ These properties are now available within the standard `detail` property
27672767
of the `PerformanceEntry` object. The existing accessors have been
27682768
deprecated and should no longer be used.
27692769

2770+
### DEP0XXX: `.aborted` property and `'abort'`, `'aborted'` event in `http`
2771+
<!-- YAML
2772+
changes:
2773+
- version: REPLACEME
2774+
pr-url: https://github.com/nodejs/node/pull/36670
2775+
description: Documentation-only deprecation.
2776+
-->
2777+
2778+
Type: Documentation-only
2779+
2780+
Move to {Stream} API instead, as the [`http.ClientRequest`][],
2781+
[`http.ServerResponse`][], and [`http.IncomingMessage`][] are all stream-based.
2782+
Check `stream.destroyed` instead of the `.aborted` property, and listen for
2783+
`'close'` instead of `'abort'`, `'aborted'` event.
2784+
2785+
The `.aborted` property and `'abort'` event are only useful for detecting
2786+
`.abort()` calls. For closing a request early, use the Stream
2787+
`.destroy([error])` then check the `.destroyed` property and `'close'` event
2788+
should have the same effect. The receiving end should also check the
2789+
[`readable.readableEnded`][] value on [`http.IncomingMessage`][] to get whether
2790+
it was an aborted or graceful destroy.
2791+
27702792
[Legacy URL API]: url.md#url_legacy_url_api
27712793
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
27722794
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -2822,6 +2844,9 @@ deprecated and should no longer be used.
28222844
[`fs.read()`]: fs.md#fs_fs_read_fd_buffer_offset_length_position_callback
28232845
[`fs.readSync()`]: fs.md#fs_fs_readsync_fd_buffer_offset_length_position
28242846
[`fs.stat()`]: fs.md#fs_fs_stat_path_options_callback
2847+
[`http.ClientRequest`]: #http_class_http_clientrequest
2848+
[`http.IncomingMessage`]: #http_class_http_incomingmessage
2849+
[`http.ServerResponse`]: #http_class_http_serverresponse
28252850
[`http.get()`]: http.md#http_http_get_options_callback
28262851
[`http.request()`]: http.md#http_http_request_options_callback
28272852
[`https.get()`]: https.md#https_https_get_options_callback
@@ -2834,6 +2859,7 @@ deprecated and should no longer be used.
28342859
[`process.env`]: process.md#process_process_env
28352860
[`process.mainModule`]: process.md#process_process_mainmodule
28362861
[`punycode`]: punycode.md
2862+
[`readable.readableEnded`]: stream.md#stream_readable_readableended
28372863
[`request.abort()`]: http.md#http_request_abort
28382864
[`request.connection`]: http.md#http_request_connection
28392865
[`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)
Please sign in to comment.