Skip to content

fix: snapshot connection metadata #413

Closed

Description

@electrohyun

Description

Connection metadata crosses reference boundaries in Smocket that Socket.IO encodes as JSON. handshake.auth retains the caller's original graph, and a middleware connect_error passes the server Error and its data by reference to the client. Socket.IO 4.7.5 and 4.8.3 expose separate decoded graphs, convert JSON values such as Date, omit unsupported properties, and do not forward arbitrary Error properties. Both paths should reuse the JSON snapshot boundary accepted in ADR 0026.

Reproduction

const auth = { nested: { count: 1 }, date: new Date(), missing: undefined };
const client = connect(url, { auth });
const serverSocket = await server.nextConnection();

auth.nested.count = 2;
// Socket.IO keeps handshake.auth.nested.count at 1.
// Smocket 0.5.1 observes 2 and retains the Date object.

server.use((_socket, next) => {
  const error = new Error('denied');
  error.data = { nested: { count: 1 }, date: new Date() };
  next(error);
});
// Smocket delivers the same Error and data references to connect_error.

smocket version

0.5.1

Environment

Node 24.11.1, Vitest 4.1.10, Socket.IO 4.7.5 and 4.8.3

Activity

  1. added this to the v1.0.0 milestone on Aug 26, 2026
  2. added
    bug
    on Aug 26, 2026
  3. moved this from Backlog to In progress in smocketon Aug 26, 2026
  4. moved this from In progress to Done in smocketon Aug 26, 2026
  5. self-assigned this
    on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions