Skip to content

fix(client): normalize root WebSocket URLs - #5291

Merged
yusukebe merged 1 commit into
honojs:mainfrom
Ersaoktaviannn:fix/client-ws-root-index
Aug 27, 2026
Merged

yusukebe merged 1 commit into
honojs:mainfrom
Ersaoktaviannn:fix/client-ws-root-index

Conversation

@Ersaoktaviannn

Copy link
Copy Markdown
Contributor

Summary

  • normalize the Hono Client index alias before constructing WebSocket URLs
  • keep protocol translation, query serialization, and custom WebSocket providers unchanged
  • preserve real path parameter values equal to index

Before / after

Typed route Before After
client.index.$ws() for / ws://host/index ws://host/
nested root route ws://host/api/index ws://host/api
/:id with id: "index" ws://host/index unchanged

Impact

index is the client-side alias for a root route. $get(), $url(), and $path() already remove that synthetic segment, but $ws() did not. As a result, a typed WebSocket client for / attempted its handshake against /index (and a nested root against /api/index), which targets a different route and commonly returns 404.

Normalization runs before path parameter substitution, so a genuine dynamic value named index is not removed.

Verification

  • npx vitest --run src/client/client.test.ts — 119 passed
  • npx vitest --run src/client/types.test.ts --coverage.enabled=false — 13 passed
  • npx tsc -p tsconfig.spec.json --pretty false
  • Prettier, ESLint, and git diff --check on the changed files

The author should do the following, if applicable

  • Add tests
  • Run focused tests and type checking
  • Format and lint the changed files
  • Add TSDoc/JSDoc — no public API added

The index segment is a client-side alias for root routes. Apply the existing normalization before path parameter substitution so $ws() targets the declared endpoint while preserving dynamic values named index.
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.88%. Comparing base (5e5b83d) to head (564adb9).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5291   +/-   ##
=======================================
  Coverage   79.88%   79.88%           
=======================================
  Files         156      156           
  Lines       10925    10926    +1     
  Branches     2301     2301           
=======================================
+ Hits         8727     8728    +1     
  Misses       2198     2198           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yusukebe yusukebe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe

Copy link
Copy Markdown
Member

@Ersaoktaviannn Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants