Skip to content

Commit 3e204fd

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 <[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 f182b9b commit 3e204fd

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
@@ -2831,6 +2831,28 @@ Type: Documentation-only (supports [`--pending-deprecation`][])
28312831
The remapping of specifiers ending in `"/"` like `import 'pkg/x/'` is deprecated
28322832
for package `"exports"` and `"imports"` pattern resolutions.
28332833

2834+
### DEP0XXX: `.aborted` property and `'abort'`, `'aborted'` event in `http`
2835+
<!-- YAML
2836+
changes:
2837+
- version: REPLACEME
2838+
pr-url: https://github.com/nodejs/node/pull/36670
2839+
description: Documentation-only deprecation.
2840+
-->
2841+
2842+
Type: Documentation-only
2843+
2844+
Move to {Stream} API instead, as the [`http.ClientRequest`][],
2845+
[`http.ServerResponse`][], and [`http.IncomingMessage`][] are all stream-based.
2846+
Check `stream.destroyed` instead of the `.aborted` property, and listen for
2847+
`'close'` instead of `'abort'`, `'aborted'` event.
2848+
2849+
The `.aborted` property and `'abort'` event are only useful for detecting
2850+
`.abort()` calls. For closing a request early, use the Stream
2851+
`.destroy([error])` then check the `.destroyed` property and `'close'` event
2852+
should have the same effect. The receiving end should also check the
2853+
[`readable.readableEnded`][] value on [`http.IncomingMessage`][] to get whether
2854+
it was an aborted or graceful destroy.
2855+
28342856
[Legacy URL API]: url.md#legacy-url-api
28352857
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
28362858
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -2888,6 +2910,9 @@ for package `"exports"` and `"imports"` pattern resolutions.
28882910
[`fs.read()`]: fs.md#fsreadfd-buffer-offset-length-position-callback
28892911
[`fs.readSync()`]: fs.md#fsreadsyncfd-buffer-offset-length-position
28902912
[`fs.stat()`]: fs.md#fsstatpath-options-callback
2913+
[`http.ClientRequest`]: #http_class_http_clientrequest
2914+
[`http.IncomingMessage`]: #http_class_http_incomingmessage
2915+
[`http.ServerResponse`]: #http_class_http_serverresponse
28912916
[`http.get()`]: http.md#httpgetoptions-callback
28922917
[`http.request()`]: http.md#httprequestoptions-callback
28932918
[`https.get()`]: https.md#httpsgetoptions-callback
@@ -2900,6 +2925,7 @@ for package `"exports"` and `"imports"` pattern resolutions.
29002925
[`process.env`]: process.md#processenv
29012926
[`process.mainModule`]: process.md#processmainmodule
29022927
[`punycode`]: punycode.md
2928+
[`readable.readableEnded`]: stream.md#stream_readable_readableended
29032929
[`request.abort()`]: http.md#requestabort
29042930
[`request.connection`]: http.md#requestconnection
29052931
[`request.destroy()`]: http.md#requestdestroyerror

doc/api/http.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,11 @@ body which has been transmitted are equal or not.
407407
### Event: `'abort'`
408408
<!-- YAML
409409
added: v1.4.1
410+
deprecated: REPLACEME
410411
-->
411412

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

@@ -564,7 +567,7 @@ added: v0.7.8
564567
-->
565568

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

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

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

658+
> Stability: 0 - Deprecated. Check [`request.destroyed`][] instead.
659+
654660
* {boolean}
655661

656662
The `request.aborted` property will be `true` if the request has
@@ -1972,8 +1978,11 @@ may be reused multiple times in case of keep-alive.
19721978
### Event: `'aborted'`
19731979
<!-- YAML
19741980
added: v0.3.8
1981+
deprecated: REPLACEME
19751982
-->
19761983

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

19791988
### Event: `'close'`
@@ -1986,8 +1995,11 @@ Indicates that the underlying connection was closed.
19861995
### `message.aborted`
19871996
<!-- YAML
19881997
added: v10.1.0
1998+
deprecated: REPLACEME
19891999
-->
19902000

2001+
> Stability: 0 - Deprecated. Check `message.destroyed` from {stream.Readable}.
2002+
19912003
* {boolean}
19922004

19932005
The `message.aborted` property will be `true` if the request has
@@ -3221,6 +3233,7 @@ try {
32213233
[`outgoingMessage.socket`]: #outgoingmessagesocket
32223234
[`removeHeader(name)`]: #requestremoveheadername
32233235
[`request.destroy()`]: #requestdestroyerror
3236+
[`request.destroyed`]: #http_request_destroyed
32243237
[`request.end()`]: #requestenddata-encoding-callback
32253238
[`request.flushHeaders()`]: #requestflushheaders
32263239
[`request.getHeader()`]: #requestgetheadername

0 commit comments

Comments
 (0)