Repository navigation
feat: preserve Socket.IO event maps - #210
Conversation
|
Warning Review limit reached
Next review available in: 35 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 (1)
📝 WalkthroughWalkthroughThe PR adds Socket.IO-compatible event-map generics across contracts and mock-server APIs. It preserves permissive defaults, adds compile-time validation, exports ChangesEvent-map typing
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
Possibly related PRs
Suggested labels: 🚥 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
🧹 Nitpick comments (1)
src/contract.ts (1)
180-183: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAlign the client-side
emitWithAckconstraints to Socket.IO’s ack-only semantics.
TimeoutEmitterContractandVolatileClientSocketcurrently allow events without an acknowledgement callback, so a non-ack event can callemitWithAck, drop the real last argument viaAllButLast, and resolveunknownviaFirstAckValue. Real Socket.IO clients constrainemitWithAckto ack-enabled events. Apply the sameEventNameWithAck<EmitEvents>constraint at both client positions.♻️ Proposed alignment
emitWithAck<Event extends EventNameWithAck<EmitEvents>>( event: Event, ...args: allButLast<EventParams<EmitEvents, Event>> ): Promise<FirstAckValue<Last<EventParams<EmitEvents, Event>>>>> ; </diff </details> </verification_result> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.In
@src/contract.tsaround lines 180 - 183, Update the emitWithAck generic
constraint in both TimeoutEmitterContract and VolatileClientSocket to use
EventNameWithAck instead of EventName, while preserving
the existing argument and return-type definitions.</details> <!-- cr-comment:v1:4017edca12d2b39542f0cac8 --> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>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@docs/decisions/0021-event-maps-cross-the-substitution-seam.md:
- Around line 1-5: Update
docs/decisions/0021-event-maps-cross-the-substitution-seam.md:1-5 by adding the
matching Korean decision file
docs/decisions/0021-event-maps-cross-the-substitution-seam.ko.md and its row in
the Korean decisions README. Update docs/test-runner-integration.md:187-215 by
adding the “Preserving application event maps” section to
docs/test-runner-integration.ko.md and mirror annotation removals at lines
36-44, 71-72, and 135-146.In
@src/contract.ts:
- Around line 830-884: Widen ServerSocketParityContract and
ClientSocketParityContract in src/contract.ts (lines 830-884) to include every
non-listener member of the corresponding Socket.IO contracts, especially emit,
emitWithAck, timeout, and volatile; retain use in ServerParityContract and
NamespaceParityContract. In src/setup-real-server.ts (lines 32-35), update the
justification to identify only listener members as unproven, or preserve a
narrower assignment that structurally checks the non-listener members.
Nitpick comments:
In@src/contract.ts:
- Around line 180-183: Update the emitWithAck generic constraint in both
TimeoutEmitterContract and VolatileClientSocket to use
EventNameWithAck instead of EventName, while preserving
the existing argument and return-type definitions.</details> <details> <summary>🪄 Autofix</summary> Fix all unresolved CodeRabbit comments on this PR: - [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended) - [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes </details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Path: .coderabbit.yaml **Review profile**: CHILL **Plan**: Pro Plus **Run ID**: `1292ac15-54ca-4dc1-b89a-7b5ba21ffbde` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between b63346fc455b6af3531d413092b5176153f01276 and 76ba4b7618b200be303cf83bfdddaf2dddeb0da0. </details> <details> <summary>📒 Files selected for processing (8)</summary> * `docs/decisions/0021-event-maps-cross-the-substitution-seam.md` * `docs/decisions/README.md` * `docs/test-runner-integration.md` * `src/contract.ts` * `src/event-maps.typecheck.ts` * `src/index.ts` * `src/mock-server.ts` * `src/setup-real-server.ts` </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
76ba4b7 to
3f37e0b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
3f37e0b to
197de44
Compare
|
@coderabbitai Regarding the emitWithAck nit: I verified this against both socket.io-client 4.7.5 and 4.8.x and did not apply the suggested ack-only constraint. The client declaration intentionally uses EventNames, while the server socket uses EventNamesWithAck. Restricting TimeoutEmitterContract or VolatileClientSocket would therefore make smocket narrower than the client API it substitutes. The compile-only fixture now includes the non-ack client case on both the real and smocket shapes so this distinction stays explicit. |
|
Tip For best results, initiate chat on the files or code changes.
✏️ Learnings added
You are interacting with an AI system. |
197de44 to
0b95e2d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/event-maps.typecheck.ts`:
- Around line 67-75: Extend both server assertion sections in
assertRealSocketIoListenerInferenceCompiles to cover IoServer emit,
room/namespace filtering, and timeout().emit acknowledgement result typing using
the existing real Socket.IO generics. Preserve the current callback type
assertions, and do not add ServerSideEvents delivery cases.
🪄 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: 93b8546a-2b17-48f7-83dd-edb6145ba41b
📒 Files selected for processing (6)
docs/decisions/0021-event-maps-cross-the-substitution-seam.mdsrc/contract.tssrc/event-maps.typecheck.tssrc/mock-server.tssrc/setup-real-server.tsvitest.config.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/setup-real-server.ts
- docs/decisions/0021-event-maps-cross-the-substitution-seam.md
- src/mock-server.ts
- src/contract.ts
0b95e2d to
79f24fa
Compare
79f24fa to
fd5240b
Compare
Summary
SocketDatadefault, acknowledgement selection, and reserved disconnect listener types aligned with Socket.IO.Type compatibility
socket.data.emitWithAckaccepts acknowledgement callbacks that carry a response value; the client retains socket.io-client's wider event-name rule.ServerSideEventspreserves Socket.IO's generic position without adding multi-server behavior.connectandiofunctions remain non-generic, matching socket.io-client.Related issue
Closes #171
Verification
pnpm vitest run(48 files, 402 tests)pnpm test:dist(21 files, 172 tests)pnpm typecheckpnpm lintpnpm format:checkpnpm check:conformancepnpm check:package