Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ can be used to specify the character encoding used to decode the stdout and
stderr output. If `encoding` is `'buffer'`, or an unrecognized character
encoding, `Buffer` objects will be passed to the callback instead.

> Stability: 0 - Deprecated. Using the `signal` option to destroy long-lived
> child process resources is documentation-only deprecated. See
> [DEP0208](deprecations.md#dep0208-using-abortsignal-to-dispose-of-resources).

```cjs
const { exec } = require('node:child_process');
exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
Expand Down Expand Up @@ -390,6 +394,10 @@ except that it does not spawn a shell by default. Rather, the specified
executable `file` is spawned directly as a new process making it slightly more
efficient than [`child_process.exec()`][].

> Stability: 0 - Deprecated. Using the `signal` option to destroy long-lived
> child process resources is documentation-only deprecated. See
> [DEP0208](deprecations.md#dep0208-using-abortsignal-to-dispose-of-resources).

The same options as [`child_process.exec()`][] are supported. Since a shell is
not spawned, behaviors such as I/O redirection and file globbing are not
supported.
Expand Down Expand Up @@ -585,6 +593,10 @@ current process.
The `shell` option available in [`child_process.spawn()`][] is not supported by
`child_process.fork()` and will be ignored if set.

> Stability: 0 - Deprecated. Using the `signal` option to destroy long-lived
> child process resources is documentation-only deprecated. See
> [DEP0208](deprecations.md#dep0208-using-abortsignal-to-dispose-of-resources).

If the `signal` option is enabled, calling `.abort()` on the corresponding
`AbortController` is similar to calling `.kill()` on the child process except
the error passed to the callback will be an `AbortError`:
Expand Down Expand Up @@ -735,6 +747,10 @@ process, the default is [`process.env`][].

`undefined` values in `env` will be ignored.

> Stability: 0 - Deprecated. Using the `signal` option to destroy long-lived
> child process resources is documentation-only deprecated. See
> [DEP0208](deprecations.md#dep0208-using-abortsignal-to-dispose-of-resources).

Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the
exit code:

Expand Down
79 changes: 79 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4643,6 +4643,85 @@
`res.writableFinished` to confirm whether the response was written
successfully before the response closed.

### DEP0208: Using `AbortSignal` to dispose of resources

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/99999

Check warning on line 4651 in doc/api/deprecations.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
description: Documentation-only deprecation.
-->

Type: Documentation-only

Using `AbortSignal` to destroy long-lived resources is deprecated. Prefer
`using` for resource cleanup.

`AbortSignal` is still a good fit for canceling actions, propagating
cancellation from the outside, and timeouts.

```js
// Deprecated
async function example() {
const ac = new AbortController();
const server = http.createServer(handler);
server.listen({ port: 3000, signal: ac.signal });

await doWork();
ac.abort();
}
```

```js
// Use this instead
async function example() {
await using server = http.createServer(handler);
server.listen(3000);

await doWork();
}
```

```js
// Deprecated
async function example() {
const ac = new AbortController();
const stream = addAbortSignal(ac.signal, fs.createReadStream(file));

await consume(stream);
ac.abort();
}
```

```js
// Use this instead
async function example() {
await using stream = fs.createReadStream(file);

await consume(stream);
}
```

```js
// Deprecated
async function example() {
const ac = new AbortController();
const child = spawn(command, args, { signal: ac.signal });

await doWork();
ac.abort();
}
```

```js
// Use this instead
async function example() {
using child = spawn(command, args);

await doWork();
}
```

[DEP0142]: #dep0142-repl_builtinlibs
[DEP0156]: #dep0156-aborted-property-and-abort-aborted-event-in-http
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
Expand Down
4 changes: 4 additions & 0 deletions doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,10 @@ Otherwise, if `path` is specified, it behaves the same as
[`server.listen(path[, backlog][, callback])`][`server.listen(path)`].
If none of them is specified, an error will be thrown.

> Stability: 0 - Deprecated. Using the `signal` option to destroy long-lived
> server resources is documentation-only deprecated. See
> [DEP0208](deprecations.md#dep0208-using-abortsignal-to-dispose-of-resources).

If `exclusive` is `false` (default), then cluster workers will use the same
underlying handle, allowing connection handling duties to be shared. When
`exclusive` is `true`, the handle is not shared, and attempted port sharing
Expand Down
4 changes: 4 additions & 0 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -3555,6 +3555,10 @@ changes:
Attaches an AbortSignal to a readable or writeable stream. This lets code
control stream destruction using an `AbortController`.

> Stability: 0 - Deprecated. Using [`stream.addAbortSignal()`][] to destroy
> long-lived stream resources is documentation-only deprecated. See
> [DEP0208](deprecations.md#dep0208-using-abortsignal-to-dispose-of-resources).

Calling `abort` on the `AbortController` corresponding to the passed
`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`
on the stream, and `controller.error(new AbortError())` for webstreams.
Expand Down
Loading