Skip to content

stream: rename Duplex.toWeb() type option to readableType#61632

Open
Renegade334 wants to merge 2 commits intonodejs:mainfrom
Renegade334:duplex-toweb-readable-type-option
Open

stream: rename Duplex.toWeb() type option to readableType#61632
Renegade334 wants to merge 2 commits intonodejs:mainfrom
Renegade334:duplex-toweb-readable-type-option

Conversation

@Renegade334
Copy link
Member

The webstreams standard uses the name readableType for a source property which specifies the type of the readable component of a constructed readable-writable pair.1 Although this is only future-proofed nomenclature at the moment, we should probably follow this convention here, for consistency and just in case we also need to support WritableStream types in the future.

This paradigm would also be consistent with Duplex.toWeb() taking readableStrategy and writableStrategy options in the future, if so desired.

Because Duplex.toWeb() is no longer marked as experimental, I believe that removing options.type entirely would need a full deprecation cycle, so I've just turned it into a silent alias for simplicity.

Refs: #58664

Footnotes

  1. https://streams.spec.whatwg.org/#dictdef-transformer

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. web streams labels Feb 2, 2026
@Renegade334 Renegade334 added the stream Issues and PRs related to the stream subsystem. label Feb 2, 2026
@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.73%. Comparing base (6c44d31) to head (c16967a).
⚠️ Report is 60 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61632      +/-   ##
==========================================
- Coverage   89.73%   89.73%   -0.01%     
==========================================
  Files         673      675       +2     
  Lines      203948   204531     +583     
  Branches    39193    39308     +115     
==========================================
+ Hits       183022   183528     +506     
- Misses      13240    13301      +61     
- Partials     7686     7702      +16     
Files with missing lines Coverage Δ
lib/internal/webstreams/adapters.js 85.66% <100.00%> (+0.08%) ⬆️

... and 51 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Renegade334
Copy link
Member Author

cc @nodejs/streams – would be grateful for eyeballs.

@MattiasBuelens
Copy link
Contributor

This also came up during the initial implementation. But I agree, readableType is more future-proof. 👍

@mcollina
Copy link
Member

mcollina commented Feb 6, 2026

Can you do it in a non-breaking way? Add the new option and keep the old one.
Add a deprecation for the old one.

@Renegade334
Copy link
Member Author

Can you do it in a non-breaking way? Add the new option and keep the old one.

As stands, this silently accepts the old option as an alias to the new. Deprecation could follow, or we can keep this behaviour in perpetuity.

@MattiasBuelens
Copy link
Contributor

MattiasBuelens commented Feb 7, 2026

As stands, this silently accepts the old option as an alias to the new. Deprecation could follow, or we can keep this behaviour in perpetuity.

I believe @mcollina means that the old type parameter should not yet be removed from the documentation and the JSDoc types. We want to make it clear that both readableType and type are still supported, without having to look at the Node.js source code. 😉

@Renegade334
Copy link
Member Author

We want to make it clear that both readableType and type are still supported, without having to look at the Node.js source code. 😉

Would this be particularly useful?

The last precedent for this that I can recall was 68dc15e, and the documentation was just straight-up changed to reflect the renaming, even though the old name was initially left as a deprecated alias.

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A couple of nits. I would recommend just going ahead and adding a docs-only deprecation for types in deprecated.md

@Renegade334 Renegade334 requested a review from jasnell February 8, 2026 13:46
@Renegade334 Renegade334 force-pushed the duplex-toweb-readable-type-option branch from 6ed587d to c16967a Compare February 8, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. web streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants