Skip to content

feat: model shared-manager namespace teardown #254

Closed

Description

@electrohyun

Problem

ADR 0028, decided in #236, selects connection-wide namespace teardown for server-side socket.disconnect(true). Smocket currently exposes the server object as every client socket's io identity and ignores the close argument, so it cannot distinguish namespace sockets that share one logical Manager from independent connections.

Implement the selected boundary with a host-neutral in-memory Manager stand-in. This models observable Socket.IO namespace lifecycle only; it must not add a transport, fallback, heartbeat, or automatic network reconnection.

Manager grouping

Match the supported socket.io-client lookup rules. Calls for the same normalized origin reuse the cached Manager when they name distinct namespaces. A second call for a namespace already owned by that cached Manager creates an independent Manager. forceNew: true and multiplex: false also create independent Managers, so add those optional flags to the existing connection options and forward them through both fixtures.

ClientSocket.io must expose the resulting Manager identity. Clients in one group share it, while duplicate-namespace and opted-out clients do not. Do not use the Server itself as the group key: that would make one disconnect(true) close unrelated clients connected to the same server.

Disconnect lifecycle

socket.disconnect(false) continues to close only that namespace socket. socket.disconnect(true) closes every currently connected namespace socket belonging to the same Manager and leaves sockets on other Managers connected.

For every affected namespace, the server fires disconnecting and then disconnect with server namespace disconnect. Server lifecycle handlers run synchronously in namespace connection order before disconnect(true) returns. The corresponding clients subsequently observe disconnect with io server disconnect in that order. Each client becomes disconnected, clears its id, and settles pending acknowledgements through the existing disconnect path; it may reconnect only when application code calls connect() explicitly.

The fluent return correction belongs to #233. This issue must preserve that result if #233 lands first rather than introducing a competing return contract.

Reference evidence

Fresh Socket.IO and socket.io-client 4.7.5 and 4.8.3 installs produced the same manager identity, affected-socket set, reasons, and event order. Reversing namespace connection order reversed the cross-namespace server lifecycle order. Duplicate-namespace connections, forceNew: true, and multiplex: false remained connected after another Manager was closed.

Acceptance

  • Add paired real/mock cases for disconnect(false) and disconnect(true)
  • Cover shared, duplicate-namespace, forceNew, and multiplex: false Manager groups
  • Pin server and client reasons, per-socket ordering, synchronous return timing, and independent-manager isolation
  • Preserve manual reconnect, acknowledgement cleanup, namespace membership cleanup, and the fix: match fluent returns for use, connect, and disconnect #233 fluent return
  • Update the conformance report and remove the temporary known-gap entry
  • Run both test targets, type checks, package checks, and the browser gate

Related to #236

Activity

  1. added this to the v1.0.0 milestone on Aug 12, 2026
  2. added
    enhancement
    fidelity
    on Aug 12, 2026
  3. moved this from Backlog to Ready in smocketon Aug 12, 2026
  4. self-assigned this
    on Aug 12, 2026
  5. moved this from Ready to In progress in smocketon Aug 12, 2026
  6. moved this from In progress to Done in smocketon Aug 12, 2026
  7. 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

enhancementfidelity

Type

No type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions