feat(async/unstable): move Channel to options-bag constructor and split per-operation options#7106
Merged
bartlomieju merged 2 commits intoApr 27, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7106 +/- ##
==========================================
+ Coverage 94.59% 94.61% +0.01%
==========================================
Files 632 633 +1
Lines 51780 51775 -5
Branches 9324 9324
==========================================
+ Hits 48981 48985 +4
+ Misses 2225 2216 -9
Partials 574 574 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Takes `Channel` through the remaining API-shape decisions before it moves
out of `unstable_*`:
- Replace the bare `new Channel<T>(capacity?)` positional with an options
bag: `new Channel<T>(options?: ChannelOptions)` where
`ChannelOptions = { capacity?: number }`. Follows the `CircuitBreakerOptions`
/ `TtlCacheOptions` pattern already used in std and leaves room for
future construction-time options (drop policies, debug labels, etc.)
without breaking callers post-stabilization.
- Split the old combined send/receive `ChannelOptions` into
`ChannelSendOptions` and `ChannelReceiveOptions`. Frees the
`ChannelOptions` name for the constructor and lets each direction
evolve independently.
- Add a "Semantics" summary to the class JSDoc documenting FIFO order,
the intentional close() vs close(reason) asymmetry, `undefined` as a
valid value, and multi-consumer fan-out of `toReadableStream()`.
- Document and pin multi-consumer `toReadableStream()` behavior: each
call returns an independent consumer; values are distributed FIFO and
delivered to exactly one consumer.
- Inline single-use `#nextReceiver()` helper.
No behavioral changes to send/receive/close/iteration/stream semantics.
Made-with: Cursor
31819bd to
03146fb
Compare
Channel for stabilizationChannel to options-bag constructor and split per-operation options
bartlomieju
approved these changes
Apr 27, 2026
Channel to options-bag constructor and split per-operation optionsChannel to options-bag constructor and split per-operation options
Member
|
Dropping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
new Channel<T>(capacity?: number)becomesnew Channel<T>(options?: ChannelOptions)whereChannelOptions = { capacity?: number }. Matches the pattern already used in std, and leaves room for future construction-time options (drop policies, debug labels, etc.) without a second breaking change once stable. Per the style guide, single positional optionals are only fine when "inconceivable more will be added later". For a channel, more certainly will be.ChannelOptions(forsend/receive) is split intoChannelSendOptionsandChannelReceiveOptions. Frees theChannelOptionsname for the constructor and lets each direction evolve independently.close()/close(reason)asymmetry (senders always reject withChannelClosedErrorso they can recover the unsent value, receivers reject withreason),undefinedas a valid value, and multi-consumer fan-out.toReadableStream(). Adds a JSDoc note that each call returns an independent consumer and values are distributed FIFO across all consumers, plus a test that asserts this.#nextReceiver()helper into#deliverToReceiver.