Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac63754

Browse filesBrowse files
authored
stream: promote DEP0201 to runtime deprecation
PR-URL: #62173 Refs: #61632 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent b4ea323 commit ac63754
Copy full SHA for ac63754

3 files changed

+20-3Lines changed: 20 additions & 3 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/deprecations.md‎

Copy file name to clipboardExpand all lines: doc/api/deprecations.md
+4-1Lines changed: 4 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -4431,12 +4431,15 @@ import { opendir } from 'node:fs/promises';
44314431
44324432
<!-- YAML
44334433
changes:
4434+
- version: REPLACEME
4435+
pr-url: https://github.com/nodejs/node/pull/62173
4436+
description: Runtime deprecation.
44344437
- version: v25.7.0
44354438
pr-url: https://github.com/nodejs/node/pull/61632
44364439
description: Documentation-only deprecation.
44374440
-->
44384441
4439-
Type: Documentation-only
4442+
Type: Runtime
44404443
44414444
Passing the `type` option to [`Duplex.toWeb()`][] is deprecated. To specify the
44424445
type of the readable half of the constructed readable-writable pair, use the
Collapse file

‎lib/internal/webstreams/adapters.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/adapters.js
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const {
7171
} = require('internal/errors');
7272

7373
const {
74+
getDeprecationWarningEmitter,
7475
kEmptyObject,
7576
normalizeEncoding,
7677
} = require('internal/util');
@@ -650,6 +651,12 @@ function newStreamReadableFromReadableStream(readableStream, options = kEmptyObj
650651
return readable;
651652
}
652653

654+
const emitDEP0201 = getDeprecationWarningEmitter(
655+
'DEP0201',
656+
"Passing 'options.type' to Duplex.toWeb() is deprecated. " +
657+
"To specify the ReadableStream type, use 'options.readableType'.",
658+
newReadableWritablePairFromDuplex);
659+
653660
/**
654661
* @typedef {import('./readablestream').ReadableWritablePair
655662
* } ReadableWritablePair
@@ -677,10 +684,15 @@ function newReadableWritablePairFromDuplex(duplex, options = kEmptyObject) {
677684

678685
const readableOptions = {
679686
__proto__: null,
680-
// DEP0201: 'options.type' is a deprecated alias for 'options.readableType'
681-
type: options.readableType ?? options.type,
687+
type: options.readableType,
682688
};
683689

690+
if (options.readableType == null && options.type != null) {
691+
// 'options.type' is a deprecated alias for 'options.readableType'
692+
emitDEP0201();
693+
readableOptions.type = options.type;
694+
}
695+
684696
if (isDestroyed(duplex)) {
685697
const writable = new WritableStream();
686698
const readable = new ReadableStream({ type: readableOptions.type });
Collapse file

‎test/parallel/test-stream-duplex.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-duplex.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,6 @@ process.on('exit', () => {
157157
// Ensure that the originally-named `options.type` still works as an alias for `options.readableType`
158158
// `getReader({ mode: 'byob' })` throws if the underlying ReadableStream is not a byte stream
159159
Duplex.toWeb(duplex, { type: 'bytes' }).readable.getReader({ mode: 'byob' });
160+
common.expectWarning('DeprecationWarning',
161+
[/Passing 'options\.type' to Duplex\.toWeb\(\) is deprecated/, 'DEP0201']);
160162
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.