Skip to content

fix: match fluent returns for use, connect, and disconnect #233

Closed

Description

@electrohyun

Description

Several Socket.IO methods are fluent at runtime and in their public declarations, but the corresponding Smocket contracts and implementations currently return void.

This issue covers only the methods whose corresponding object is the observed return value:

  • Server.use();
  • Namespace.use();
  • server Socket.disconnect();
  • client Socket.connect();
  • client Socket.disconnect().

Each method should return the same server, namespace, or socket instance it was called on. Public types must preserve event maps and socket data through the returned value, and existing call sites that ignore the result must continue to compile.

Server.on() is explicitly outside this issue. Socket.IO's declaration and runtime result conflict there: the declaration says this, while the runtime call returns the root namespace. Smocket's current void compromise must not be changed as part of a general fluent-return correction.

The return identities and declarations must be verified against Socket.IO 4.7 and 4.8 before updating the contracts. If a supported version differs, the shared contract must admit the measured declarations without inventing uniformity.

Reproduction

import { connect, Server } from 'smocket';

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

console.log(io.use((_socket, next) => next()) === io); // expected: true
console.log(namespace.use((_socket, next) => next()) === namespace); // expected: true
console.log(client.disconnect() === client); // expected: true
console.log(client.connect() === client); // expected: true
console.log(socket.disconnect() === socket); // expected: true

Completion requires runtime identity assertions and consumer type fixtures for all five methods, including chained use with non-default event maps.

smocket version

0.4.2

Environment

Node 22, Vitest 4; Socket.IO and socket.io-client 4.8.3 reference probes and declarations, 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. self-assigned this
    on Aug 12, 2026
  4. moved this from Backlog to In progress in smocketon Aug 12, 2026
  5. moved this from In progress to Done in smocketon 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