Skip to content

docs: define the payload snapshot boundary - #252

Merged
electrohyun merged 1 commit into
mainfrom
docs/payload-serialization-boundary
Aug 12, 2026
Merged

electrohyun merged 1 commit into
mainfrom
docs/payload-serialization-boundary

Conversation

@electrohyun

Copy link
Copy Markdown
Owner

Summary

Reference behavior

Fresh Socket.IO 4.7.5 and 4.8.3 installations both resolved socket.io-parser 4.2.7. Runtime probes in Node and Chromium produced the same default-parser behavior in both versions.

Connected client-to-server and server-to-client emits snapshot non-binary packet data synchronously. Mutating the source after emit does not change the received value. Acknowledgement requests snapshot at emit, and acknowledgement responses snapshot when the receiver invokes the ack. A client emit buffered before connection is different: its source remains live until the buffer flushes, and the snapshot is taken then.

Decoded data follows JSON conversion. Dates arrive as ISO strings, undefined object properties disappear, unsupported array positions and non-finite numbers become null, toJSON is honored, and custom prototypes become plain objects. Map, Set, RegExp, and Error retain only enumerable own properties. Repeated references decode as separate objects, while circular data and BigInt fail when encoding is attempted.

Broadcast probes showed that Socket.IO encodes one packet at the broadcast call even when there are no recipients. Each recipient decodes an independent object graph, so later mutation of the source and mutation by one recipient cannot affect another recipient.

The probes also fixed the boundary relative to onAnyOutgoing. A connected direct emit exposes the live source to the sending-side listener before snapshotting. A buffered client does not notify at the original emit; it notifies and snapshots at flush. A broadcast snapshots first, then each reached server socket's outgoing listener sees the shared source without being able to change any recipient's encoded value.

Decision

ADR 0026 selects the default parser's JSON result, reference isolation, and snapshot or failure timing as Smocket's compatibility boundary for non-binary EVENT and ACK data. This applies to direct emits, acknowledgements, broadcasts, timeout wrappers, connected volatile emits, and buffered delivery in both directions.

The decision does not promise Socket.IO's internal traversal algorithm, getter or toJSON invocation counts, or exact native exception classes and messages. Binary-containing packets, Engine.IO framing, and custom parser options stay outside this boundary. The implementation must remain host-neutral and add no Socket.IO runtime dependency.

Normalizing only Date was rejected because it would leave the rest of the packet boundary observably wrong. Keeping direct references would permit tests to rely on reference sharing that real Socket.IO cannot provide. structuredClone preserves types and graph aliases that the default parser removes, while depending on socket.io-parser would import binary and parser machinery beyond the selected logic-layer surface.

Follow-up and release boundary

Issue #250 now owns implementation with paired real/mock coverage for both directions, acknowledgements, connected and buffered timing, broadcast recipient isolation, outgoing catch-all ordering, invalid JSON data, timeout and volatile wrappers, and the browser gate.

Until #250 lands, docs/differences.md records direct same-process payload references as a known gap rather than an intentional divergence. The decision index and v1 roadmap now link the ADR and its implementation dependency. ADR 0019 classifies the eventual newly covered surface as minor after 1.0 and patch before 1.0.

Related issue

Closes #237

Checklist

  • Tests added or updated (not applicable: documentation-only decision)
  • Behavior verified against real socket.io

@github-actions github-actions Bot added documentation Improvements or additions to documentation 📏 m Pull request changes 50–199 lines labels Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 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: 18 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: ff5a1e33-bde3-457b-acc2-5f19ec7a852c

📥 Commits

Reviewing files that changed from the base of the PR and between bc0dd4d and c48dc61.

📒 Files selected for processing (4)
  • docs/decisions/0026-payloads-cross-a-json-snapshot-boundary.md
  • docs/decisions/README.md
  • docs/differences.md
  • docs/roadmap.md

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.

@electrohyun
electrohyun merged commit 1a11936 into main Aug 12, 2026
14 checks passed
@electrohyun
electrohyun deleted the docs/payload-serialization-boundary branch August 12, 2026 08:21
@electrohyun electrohyun self-assigned this Aug 12, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in smocket Aug 27, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in smocket Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation 📏 m Pull request changes 50–199 lines

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat: define the payload serialization boundary

1 participant