Skip to content

Commit 80ee6ee

Browse files
dr-jstargos
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 <targos@protonmail.com>
1 parent 75afb6c commit 80ee6ee

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

doc/api/deprecations.md

+24
Original file line numberDiff line numberDiff line change
@@ -2699,6 +2699,27 @@ resolutions not in `node_modules`. This means there will not be deprecation
26992699
warnings for `"exports"` in dependencies. With `--pending-deprecation`, a
27002700
runtime warning results no matter where the `"exports"` usage occurs.
27012701

2702+
<a id="DEP0XXX"></a>
2703+
### DEP0XXX: `.aborted` property and `'abort'`, `'aborted'` event in `http`
2704+
<!-- YAML
2705+
changes:
2706+
- version: REPLACEME
2707+
pr-url: https://github.com/nodejs/node/pull/36670
2708+
description: Documentation-only deprecation.
2709+
-->
2710+
2711+
Type: Documentation-only
2712+
2713+
Move to {Stream} API instead, as the [`http.ClientRequest`][],
2714+
[`http.ServerResponse`][], and [`http.IncomingMessage`][] are all stream-based.
2715+
Check `stream.destroyed` instead of the `.aborted` property, and listen for
2716+
`'close'` instead of `'abort'`, `'aborted'` event.
2717+
2718+
The `.aborted` property and `'abort'` event is only useful for detecting
2719+
`.abort()` calls. For closing a request early, use the Stream
2720+
`.destroy([error])` then check the `.destroyed` property and `'close'` event
2721+
should have the same effect.
2722+
27022723
[Legacy URL API]: url.md#url_legacy_url_api
27032724
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
27042725
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -2753,6 +2774,9 @@ runtime warning results no matter where the `"exports"` usage occurs.
27532774
[`fs.read()`]: fs.md#fs_fs_read_fd_buffer_offset_length_position_callback
27542775
[`fs.readSync()`]: fs.md#fs_fs_readsync_fd_buffer_offset_length_position
27552776
[`fs.stat()`]: fs.md#fs_fs_stat_path_options_callback
2777+
[`http.ClientRequest`]: #http_class_http_clientrequest
2778+
[`http.IncomingMessage`]: #http_class_http_incomingmessage
2779+
[`http.ServerResponse`]: #http_class_http_serverresponse
27562780
[`http.get()`]: http.md#http_http_get_options_callback
27572781
[`http.request()`]: http.md#http_http_request_options_callback
27582782
[`https.get()`]: https.md#https_https_get_options_callback

doc/api/http.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,11 @@ body which has been transmitted are equal or not.
396396
### Event: `'abort'`
397397
<!-- YAML
398398
added: v1.4.1
399+
deprecated: REPLACEME
399400
-->
400401

402+
> Stability: 0 - Deprecated. Listen for the `'close'` event instead.
403+
401404
Emitted when the request has been aborted by the client. This event is only
402405
emitted on the first call to `abort()`.
403406

@@ -553,7 +556,7 @@ added: v0.7.8
553556
-->
554557

555558
Emitted when the underlying socket times out from inactivity. This only notifies
556-
that the socket has been idle. The request must be aborted manually.
559+
that the socket has been idle. The request must be destroyed manually.
557560

558561
See also: [`request.setTimeout()`][].
559562

@@ -634,12 +637,15 @@ in the response to be dropped and the socket to be destroyed.
634637
### `request.aborted`
635638
<!-- YAML
636639
added: v0.11.14
640+
deprecated: REPLACEME
637641
changes:
638642
- version: v11.0.0
639643
pr-url: https://github.com/nodejs/node/pull/20230
640644
description: The `aborted` property is no longer a timestamp number.
641645
-->
642646

647+
> Stability: 0 - Deprecated. Check [`request.destroyed`][] instead.
648+
643649
* {boolean}
644650

645651
The `request.aborted` property will be `true` if the request has
@@ -1923,8 +1929,11 @@ status, headers and data.
19231929
### Event: `'aborted'`
19241930
<!-- YAML
19251931
added: v0.3.8
1932+
deprecated: REPLACEME
19261933
-->
19271934

1935+
> Stability: 0 - Deprecated. Listen for `'close'` event instead.
1936+
19281937
Emitted when the request has been aborted.
19291938

19301939
### Event: `'close'`
@@ -1937,8 +1946,11 @@ Indicates that the underlying connection was closed.
19371946
### `message.aborted`
19381947
<!-- YAML
19391948
added: v10.1.0
1949+
deprecated: REPLACEME
19401950
-->
19411951

1952+
> Stability: 0 - Deprecated. Check `message.destroyed` from {stream.Readable}.
1953+
19421954
* {boolean}
19431955

19441956
The `message.aborted` property will be `true` if the request has
@@ -2733,6 +2745,7 @@ try {
27332745
[`removeHeader(name)`]: #http_request_removeheader_name
27342746
[`request.end()`]: #http_request_end_data_encoding_callback
27352747
[`request.destroy()`]: #http_request_destroy_error
2748+
[`request.destroyed`]: #http_request_destroyed
27362749
[`request.flushHeaders()`]: #http_request_flushheaders
27372750
[`request.getHeader()`]: #http_request_getheader_name
27382751
[`request.setHeader()`]: #http_request_setheader_name_value

0 commit comments

Comments
 (0)