Skip to content

Commit 4b030d0

Browse files
dr-jsmcollina
authored andcommitted
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]> PR-URL: #36670 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 44b173e commit 4b030d0

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
@@ -2838,6 +2838,28 @@ Type: Runtime
28382838
The remapping of specifiers ending in `"/"` like `import 'pkg/x/'` is deprecated
28392839
for package `"exports"` and `"imports"` pattern resolutions.
28402840

2841+
### DEP0XXX: `.aborted` property and `'abort'`, `'aborted'` event in `http`
2842+
<!-- YAML
2843+
changes:
2844+
- version: REPLACEME
2845+
pr-url: https://github.com/nodejs/node/pull/36670
2846+
description: Documentation-only deprecation.
2847+
-->
2848+
2849+
Type: Documentation-only
2850+
2851+
Move to {Stream} API instead, as the [`http.ClientRequest`][],
2852+
[`http.ServerResponse`][], and [`http.IncomingMessage`][] are all stream-based.
2853+
Check `stream.destroyed` instead of the `.aborted` property, and listen for
2854+
`'close'` instead of `'abort'`, `'aborted'` event.
2855+
2856+
The `.aborted` property and `'abort'` event are only useful for detecting
2857+
`.abort()` calls. For closing a request early, use the Stream
2858+
`.destroy([error])` then check the `.destroyed` property and `'close'` event
2859+
should have the same effect. The receiving end should also check the
2860+
[`readable.readableEnded`][] value on [`http.IncomingMessage`][] to get whether
2861+
it was an aborted or graceful destroy.
2862+
28412863
[Legacy URL API]: url.md#legacy-url-api
28422864
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
28432865
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -2895,6 +2917,9 @@ for package `"exports"` and `"imports"` pattern resolutions.
28952917
[`fs.read()`]: fs.md#fsreadfd-buffer-offset-length-position-callback
28962918
[`fs.readSync()`]: fs.md#fsreadsyncfd-buffer-offset-length-position
28972919
[`fs.stat()`]: fs.md#fsstatpath-options-callback
2920+
[`http.ClientRequest`]: http.md#class-httpclientrequest
2921+
[`http.IncomingMessage`]: http.md#class-httpincomingmessage
2922+
[`http.ServerResponse`]: http.md#class-httpserverresponse
28982923
[`http.get()`]: http.md#httpgetoptions-callback
28992924
[`http.request()`]: http.md#httprequestoptions-callback
29002925
[`https.get()`]: https.md#httpsgetoptions-callback
@@ -2907,6 +2932,7 @@ for package `"exports"` and `"imports"` pattern resolutions.
29072932
[`process.env`]: process.md#processenv
29082933
[`process.mainModule`]: process.md#processmainmodule
29092934
[`punycode`]: punycode.md
2935+
[`readable.readableEnded`]: stream.md#readablereadableended
29102936
[`request.abort()`]: http.md#requestabort
29112937
[`request.connection`]: http.md#requestconnection
29122938
[`request.destroy()`]: http.md#requestdestroyerror

doc/api/http.md

Lines changed: 14 additions & 1 deletion
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
@@ -1988,8 +1994,11 @@ may be reused multiple times in case of keep-alive.
19881994
### Event: `'aborted'`
19891995
<!-- YAML
19901996
added: v0.3.8
1997+
deprecated: REPLACEME
19911998
-->
19921999

2000+
> Stability: 0 - Deprecated. Listen for `'close'` event instead.
2001+
19932002
Emitted when the request has been aborted.
19942003

19952004
### Event: `'close'`
@@ -2002,8 +2011,11 @@ Indicates that the underlying connection was closed.
20022011
### `message.aborted`
20032012
<!-- YAML
20042013
added: v10.1.0
2014+
deprecated: REPLACEME
20052015
-->
20062016

2017+
> Stability: 0 - Deprecated. Check `message.destroyed` from {stream.Readable}.
2018+
20072019
* {boolean}
20082020

20092021
The `message.aborted` property will be `true` if the request has
@@ -3237,6 +3249,7 @@ try {
32373249
[`outgoingMessage.socket`]: #outgoingmessagesocket
32383250
[`removeHeader(name)`]: #requestremoveheadername
32393251
[`request.destroy()`]: #requestdestroyerror
3252+
[`request.destroyed`]: #requestdestroyed
32403253
[`request.end()`]: #requestenddata-encoding-callback
32413254
[`request.flushHeaders()`]: #requestflushheaders
32423255
[`request.getHeader()`]: #requestgetheadername

0 commit comments

Comments
 (0)