Repository navigation
feat: support except chaining on the broadcast operator - #138
Conversation
|
Warning Review limit reached
Next review available in: 46 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughBroadcast operators now support immutable chaining for ChangesBroadcast chaining
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant BroadcastOperator
participant Recipients
Caller->>BroadcastOperator: chain to/in/except/timeout
BroadcastOperator->>BroadcastOperator: create derived operator with merged sets
BroadcastOperator->>Recipients: emit to included recipients
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/broadcast-timeout.test.ts`:
- Around line 143-159: Update the excluded-recipient broadcast test around the
ask emission to use the ordering helpers from src/test-events.ts: track b’s ask
event, send a later marker to b, and await receive for that marker before
asserting ask was not received. Preserve the existing err and responses
assertions to validate acknowledgement collection, and apply the same
marker-based ordering approach to the additional covered block.
In `@src/contract.ts`:
- Around line 71-77: Update TimeoutBroadcastContract in src/contract.ts to
restore the timeout(ms: number): TimeoutBroadcastContract method so the type
remains chainable after to(), in(), and except(). Then update the Ensure<> proof
in the same file to include timeout() as part of the contract surface, keeping
the existing emit/to/in/except members unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 7fa04fa9-383b-443f-8205-f4db25322f3a
📒 Files selected for processing (6)
docs/glossary.ko.mddocs/glossary.mdsrc/broadcast-chaining.test.tssrc/broadcast-timeout.test.tssrc/contract.tssrc/mock-server.ts
f9aac82 to
f2157cb
Compare
|
@coderabbitai Neither finding is applied. Reasons below.
|
|
Tip For best results, initiate chat on the files or code changes.
✏️ Learnings added
You are interacting with an AI system. |
Add except and in to the broadcast operator, so a broadcast can be narrowed in any order. Real socket.io carries to / in / except / timeout on the operator itself, while smocket had except as an entry point only. io.except(sid).to(room) worked and io.to(room).except(sid) did not exist, which breaks the substitution path for server code written in the common ordering. TypeScript users get a type error and JavaScript users get `.except is not a function`. The gap was recorded nowhere a user can see, and neither guard looks in this direction, since the dual-run suite only exercises the forms the tests use and Ensure<> proves that everything smocket declares exists on socket.io. Chaining returns a new operator over the merged sets and leaves the one it was called on alone, measured against real socket.io 4.8.3. An operator held in a variable stays the target it was built as, and a later chained call on it builds another operator. Only the two room sets and the timeout ever differ, so every chaining method is one call to a private narrow() that carries the adapter, the socket map, and the volatile flag over. Measured and matched before the mock changed. A second except unions with the first. socket.to(room).except(other) keeps the automatic sender exclusion and adds to it. except composes with timeout in either order, and the collection then covers exactly the surviving recipients. in is an alias of to on the operator as it is at the entry point. Add dual-run tests for the chaining orders, including the namespace form, and the two timeout combinations. Non-receipt is proven with the marker pattern.
The broadcast operator entry described the object as holding the two room sets and exposing emit. It carries to / in / except / timeout as well, each returning a further operator over the merged sets, which is what lets a broadcast be narrowed in any order.
f2157cb to
eb8712a
Compare
|
Tip For best results, initiate chat on the files or code changes.
🐇 You are interacting with an AI system. |
Summary
exceptwas an entry point only, soio.except(sid).to(room)worked andio.to(room).except(sid)did not exist, which is the ordering most socket.io code is written in. It now sits on the broadcast operator next toto/in/timeout, so the order they are chained in no longer changes the recipients.injoins the operator for the same reason, since the operator hadtoand lackedinwhile real socket.io has both.Chaining returns a new operator over the merged sets and leaves the one it was called on alone, measured against real socket.io 4.8.3. An operator held in a variable stays the target it was built as, and a later chained call on it builds another operator. Only the two room sets and the timeout ever differ between operators, so each chaining method is one call to a private
narrow()that carries the adapter, the socket map, and the volatile flag over.Measured on the real target first, then matched. A second
exceptunions with the first.socket.to(room).except(other)keeps the automatic sender exclusion and adds to it.exceptcomposes withtimeoutin either order, and the ack collection then covers exactly the surviving recipients.inis an alias oftoon the operator as it is at the entry point. New dual-run tests cover the chaining orders, the namespace form, and the two timeout combinations, with non-receipt proven by the marker pattern.Related issue
Closes #137
Checklist