Skip to content

feat: support volatile emit, dropped only in the pre-connect window - #131

Merged
electrohyun merged 1 commit into
mainfrom
feat/volatile-emit
Aug 5, 2026
Merged

feat: support volatile emit, dropped only in the pre-connect window#131
electrohyun merged 1 commit into
mainfrom
feat/volatile-emit

Conversation

@electrohyun

Copy link
Copy Markdown
Owner

Summary

Adds socket.volatile.emit(...) (and io.volatile.to(room), socket.volatile.broadcast) on both sides. Per the model measured and source-confirmed against real socket.io 4.8.3 (ADR 0016): a volatile emit is an ordinary emit once the connection is settled, and is dropped only in the pre-connect window. The gate is connection state, not simulated backpressure, because a mock has no transport buffer to overflow, so pass-through in steady state is the faithful behavior; the drop reproduces transport.writable === false during the handshake write.

BroadcastOperator gains a per-recipient volatile skip (a target whose client has not completed its connection is skipped), matching real socket.io deciding volatile per recipient. Rooms, sender exclusion, and ack all behave normally otherwise. The real side needed no changes.

Scope note (documented in the test file)

The server-side pre-connect drop is cleanly observable and tested with the marker pattern on both targets. The client-side pre-connect window is not cleanly reachable through the shared harness: the only public route to a disconnected client is a reconnect, and real socket.io-client buffers a volatile emit across a reconnect (rather than dropping it), which is reconnection behavior and explicitly out of smocket's scope. That one test was removed and the reasoning recorded in volatile.test.ts; the mock's client-side gate still drops when not connected per the model, and the divergence only surfaces in the out-of-scope reconnect case.

Related issue

Closes #122

Checklist

  • Tests added or updated
  • Behavior verified against real socket.io

@electrohyun electrohyun added this to the v0.4.0 milestone Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@electrohyun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d0ac4519-a549-4ac5-9224-e4d42e684f54

📥 Commits

Reviewing files that changed from the base of the PR and between e91109c and 339770b.

📒 Files selected for processing (3)
  • src/contract.ts
  • src/mock-server.ts
  • src/volatile.test.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Implement ADR 0016: `.volatile` is a plain emit once the socket is connected,
composing with rooms, broadcast, sender exclusion, and acks, and is dropped only
when it is sent in the pre-connect window (0004), matching real socket.io's
transport-not-writable drop.

Add the `volatile` getter to the server and client socket contracts and the
`io` / namespace broadcast path, and back it with a per-target drop gate in the
existing send / BroadcastOperator path: a volatile emit to a socket whose client
has not completed its connection is skipped, otherwise it delegates to the normal
delivery. The gate keys on connection state rather than a simulated backpressure
buffer, which a mock has no source for.

The dual-run tests cover steady-state delivery in both directions, rooms,
broadcast, and acks, plus the server-side pre-connect drop proven with the marker
pattern. The client-side pre-connect window is not cleanly reachable through the
shared harness, noted in the test file.
@electrohyun
electrohyun merged commit 5d8aa7e into main Aug 5, 2026
3 checks passed
@electrohyun
electrohyun deleted the feat/volatile-emit branch August 5, 2026 06:22
@electrohyun electrohyun added the enhancement New feature or request label Aug 5, 2026
@electrohyun electrohyun self-assigned this Aug 5, 2026
@electrohyun electrohyun removed this from the v0.4.0 milestone Aug 5, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in smocket Aug 6, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in smocket Aug 6, 2026
@electrohyun electrohyun added the 📏 l Pull request changes 200–999 lines label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request 📏 l Pull request changes 200–999 lines

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat: support volatile emit, dropped only in the pre-connect window

1 participant