Skip to content

Commit 2eb751c

Browse files
dr-jstargosTrottronagaduh95
committed
doc: deprecate (doc-only) http abort related
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]> Co-authored-by: Rich Trott <[email protected]> Co-authored-by: Robert Nagy <[email protected]> Co-authored-by: Antoine du Hamel <[email protected]>
1 parent 3b40893 commit 2eb751c

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
@@ -2743,6 +2743,28 @@ Previously, `index.js` and extension searching lookups would apply to
27432743
With this deprecation, all ES module main entry point resolutions require
27442744
an explicit [`"exports"` or `"main"` entry][] with the exact file extension.
27452745

2746+
### DEP0XXX: `.aborted` property and `'abort'`, `'aborted'` event in `http`
2747+
<!-- YAML
2748+
changes:
2749+
- version: REPLACEME
2750+
pr-url: https://github.com/nodejs/node/pull/36670
2751+
description: Documentation-only deprecation.
2752+
-->
2753+
2754+
Type: Documentation-only
2755+
2756+
Move to {Stream} API instead, as the [`http.ClientRequest`][],
2757+
[`http.ServerResponse`][], and [`http.IncomingMessage`][] are all stream-based.
2758+
Check `stream.destroyed` instead of the `.aborted` property, and listen for
2759+
`'close'` instead of `'abort'`, `'aborted'` event.
2760+
2761+
The `.aborted` property and `'abort'` event are only useful for detecting
2762+
`.abort()` calls. For closing a request early, use the Stream
2763+
`.destroy([error])` then check the `.destroyed` property and `'close'` event
2764+
should have the same effect. The receiving end should also check the
2765+
[`readable.readableEnded`][] value on [`http.IncomingMessage`][] to get whether
2766+
it was an aborted or graceful destroy.
2767+
27462768
[Legacy URL API]: url.md#url_legacy_url_api
27472769
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
27482770
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -2798,6 +2820,9 @@ an explicit [`"exports"` or `"main"` entry][] with the exact file extension.
27982820
[`fs.read()`]: fs.md#fs_fs_read_fd_buffer_offset_length_position_callback
27992821
[`fs.readSync()`]: fs.md#fs_fs_readsync_fd_buffer_offset_length_position
28002822
[`fs.stat()`]: fs.md#fs_fs_stat_path_options_callback
2823+
[`http.ClientRequest`]: #http_class_http_clientrequest
2824+
[`http.IncomingMessage`]: #http_class_http_incomingmessage
2825+
[`http.ServerResponse`]: #http_class_http_serverresponse
28012826
[`http.get()`]: http.md#http_http_get_options_callback
28022827
[`http.request()`]: http.md#http_http_request_options_callback
28032828
[`https.get()`]: https.md#https_https_get_options_callback
@@ -2810,6 +2835,7 @@ an explicit [`"exports"` or `"main"` entry][] with the exact file extension.
28102835
[`process.env`]: process.md#process_process_env
28112836
[`process.mainModule`]: process.md#process_process_mainmodule
28122837
[`punycode`]: punycode.md
2838+
[`readable.readableEnded`]: stream.md#stream_readable_readableended
28132839
[`request.abort()`]: http.md#http_request_abort
28142840
[`request.connection`]: http.md#http_request_connection
28152841
[`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)