Skip to content

chore: typecheck contracts across supported socket.io minors #201

Closed

Description

@electrohyun

Current state

The compatibility job installs socket.io and socket.io-client 4.7 and 4.8 in separate matrix rows, then runs only pnpm test:real. The check job runs pnpm typecheck, but only against the lockfile version, currently 4.8.3. Runtime compatibility is therefore checked across the supported range; the compile-time contract is checked at one end of it.

That split has now hidden a concrete mismatch. ServerContract is guarded by Ensure<ServerContract, Server> so every member it declares must be satisfied by the real socket.io Server. While implementing #193, close() was first declared as returning Promise<void>, which matches socket.io 4.8. Socket.io 4.7 returns void. The 4.7 runtime row remained useful once the shared test moved to the callback form, but it had no typecheck capable of rejecting the 4.8-only contract.

The immediate mismatch belongs to #193 and should be corrected there with the common void | Promise<void> return. The CI gap is wider than close(): any future parameter or return-type difference between supported socket.io minors can pass the lockfile typecheck and every runtime row at the same time.

This is the same distinction the matrix already makes for behavior. A supported version is not covered merely because another version compiled, just as 4.7 behavior would not be covered by running 4.8 twice.

Proposed change

Run pnpm typecheck in each compat matrix row after that row pins its socket.io and socket.io-client versions, alongside the existing real-target run.

Do not duplicate lint, formatting, packaging, or the mock suite there. Those checks are not version-dependent and remain owned by their existing jobs. The additional assertion is only the one whose input the compatibility matrix changes: whether the shared contracts compile against that exact oracle version.

A working state is observable from outside:

  • both the 4.7 and 4.8 rows typecheck and run the real suite;
  • changing a shared contract to a 4.8-only shape fails the 4.7 row;
  • changing it to a 4.7-only shape fails the 4.8 row when the newer declaration is incompatible.

Keep the runtime test after typecheck. The close() return difference is itself the example for why neither check replaces the other: a callback-based runtime case can pass on both versions while their declared return types still differ.

Behavior

  • This does not change smocket's delivery behavior

Activity

  1. added
    chore
    on Aug 10, 2026
  2. moved this from Backlog to In progress in smocketon Aug 10, 2026
  3. moved this from In progress to Done in smocketon Aug 10, 2026
  4. added this to the v0.4.2 milestone on Aug 10, 2026
  5. self-assigned this
    on Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

chore

Type

No type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions