Skip to content

test: verify namespace middleware isolation #207

Closed

Description

@electrohyun

Current state

Smocket implements namespace connection middleware through io.of(namespace).use(middleware), but the conformance suite does not prove that the middleware is isolated to that namespace.

The gap is listed under Not covered yet in docs/conformance.md: namespace-level io.of(nsp).use(fn) exists, but no case pins it against real Socket.IO.

Proposed change

Add one focused case to the existing src/middleware.test.ts.

The case should:

  1. Register middleware on /admin.
  2. Connect one client to /.
  3. Verify that the middleware has not run.
  4. Connect another client to /admin.
  5. Verify that the middleware has run exactly once.

Use connection completion as the ordering marker. Do not add a timeout to prove that the default-namespace connection skipped the middleware.

No runtime implementation change is required.

Completion:

  • The case passes with pnpm test:real.
  • The same case passes with pnpm test:mock.
  • pnpm conformance has been run and the generated docs/conformance.md change is committed.
  • pnpm typecheck, pnpm lint, and pnpm format:check pass.

Behavior

  • This does not change smocket's delivery behavior

Activity

  1. added this to the v1.0.0 milestone on Aug 10, 2026
  2. added
    good first issue
    test
    on Aug 10, 2026
  3. electrohyun commented on Aug 10, 2026

    @electrohyun
    OwnerAuthor

    🇰🇷 한국어 안내

    이 이슈를 해결하기 위해 Smocket의 전체 구현을 이해할 필요는 없습니다.

    기존 src/middleware.test.ts에 테스트 하나를 추가합니다. /admin에 등록한 미들웨어가 기본 네임스페이스 / 연결에는 실행되지 않고, /admin 연결에서만 정확히 한 번 실행되는지 확인하면 돼요.

    먼저 실제 Socket.IO 대상으로 테스트하고, 같은 테스트를 Smocket 대상으로 실행합니다. 런타임 구현은 수정하지 않습니다.

    테스트 이름을 추가하면 conformance 문서도 함께 갱신해야 해요. 작업 중 예상과 다른 결과가 나오면 편하게 이슈에 남겨주세요.

  4. moved this from Backlog to In progress in smocketon Aug 10, 2026
  5. moved this from In progress to Done in smocketon Aug 10, 2026
  6. 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

good first issuetest

Type

No type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions