Skip to content

feat: define the payload serialization boundary #237

Closed

Description

@electrohyun

Problem

Smocket delivers payload objects directly between paired in-memory emitters. Real Socket.IO sends serializable packet data across an encoding boundary, so some application-visible values do not retain the same shape or reference identity.

A Socket.IO 4.8.3 probe observed that a Date arrives as an ISO string, while Smocket currently delivers the same Date instance. Binary encoding and Engine.IO framing are explicitly outside Smocket's scope, but the minimum JSON-safe payload boundary within the supported logic layer has not been decided.

Before v1, decide whether Smocket should:

  • normalize only values with a clear, required application-visible result such as Date;
  • reproduce a broader JSON-safe serialization boundary;
  • or deliberately retain same-process references and document the difference.

The decision must address circular values, prototypes, mutation timing, reference sharing, errors, browser and Node behavior, and the cost of applying the rule consistently in both delivery directions. It must not accidentally promise binary encoding or full Socket.IO parser compatibility.

Proposed API

const sentAt = new Date('2026-01-02T03:04:05.000Z');

client.emit('message', { sentAt });

serverSocket.on('message', (payload) => {
  // Decision required: ISO string, a cloned value, or the original Date reference?
  console.log(payload.sentAt);
  console.log(payload.sentAt === sentAt);
});

Record the selected semantic boundary in an ADR. If normalization is selected, create a separate implementation issue with paired runtime tests for both directions, acknowledgements, buffered delivery, and broadcast wrappers. If direct references remain intentional, document the divergence in docs/differences.md.

Socket.IO behavior

Socket.IO 4.8.3 was observed to serialize Date as an ISO string across delivery. The result for Socket.IO 4.7, acknowledgements, nested values, mutation timing, unsupported circular structures, and relevant parser options remains unverified and must be measured before choosing an implementation scope.

This issue does not propose binary encoding, Engine.IO framing, transport fallback, heartbeat, automatic reconnection, or Redis multi-server behavior.

Scope check

  • This is not reconnection, transport fallback, heartbeat, Redis multi-server, or binary encoding

Activity

  1. added this to the v1.0.0 milestone on Aug 12, 2026
  2. added
    enhancement
    fidelity
    needs decision
    on Aug 12, 2026
  3. moved this from Backlog to In progress in smocketon Aug 12, 2026
  4. moved this from In progress to Done in smocketon Aug 12, 2026
  5. self-assigned this
    on Aug 12, 2026
  6. modified the milestones: v1.0.0, v0.5.0 on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementfidelityneeds decision

Type

No type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions