Skip to content

fix: reject reserved event names on public emit surfaces #232

Closed

Description

@electrohyun

Description

Smocket filters reserved lifecycle events out of catch-all listeners, but its public emit() surfaces do not reject those event names. An application can therefore emit a reserved event to a peer where Socket.IO throws before delivery.

Socket.IO 4.8.3 exposes side-specific reserved-event checks on its server and client emit paths. The observed sets include connect, connect_error, disconnect, disconnecting, newListener, and removeListener, but the exact set, error text, and surface coverage must be measured independently for Socket.IO 4.7 and 4.8 rather than assumed to be one shared constant.

The correction must cover every reachable public emit surface: Server, Namespace, BroadcastOperator, server Socket, client Socket, and timeout or volatile wrappers that delegate to them. A rejected emit must not deliver to the peer or fire an outgoing catch-all listener.

Runtime checks and public event-map constraints should agree where TypeScript can express the restriction. Existing lifecycle dispatch inside Smocket must continue to work because internal dispatch is not an application emit().

Reproduction

import { connect, Server } from 'smocket';

const URL = 'http://localhost:3000';
const io = new Server(URL);
const client = connect(URL);
const socket = await io.nextConnection();

// Socket.IO rejects application emits that use reserved lifecycle names.
client.emit('disconnect');
socket.emit('disconnect');
io.emit('disconnect');
io.of('/').emit('disconnect');
io.to('room').emit('disconnect');

Completion requires paired tests for valid and invalid names on every public surface, including proof that invalid names do not reach peer listeners or outgoing catch-alls. The exact error assertions must come from the supported-version probes.

smocket version

0.4.2

Environment

Node 22, Vitest 4; Socket.IO and socket.io-client 4.8.3 reference probes, with Socket.IO 4.7 and 4.8 verification required

Activity

  1. added this to the v0.4.3 milestone on Aug 12, 2026
  2. added
    bug
    fidelity
    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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugfidelity

Type

No type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions