Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testClient doesn't support websocket route #2490

Closed
goshander opened this issue Apr 9, 2024 · 4 comments · Fixed by #2496
Closed

testClient doesn't support websocket route #2490

goshander opened this issue Apr 9, 2024 · 4 comments · Fixed by #2496
Labels
enhancement New feature or request.

Comments

@goshander
Copy link

What is the feature you are proposing?

const ws = await client.ws.$ws() throw an error before try to create real WebSocket client

112 |     return new URL(url);
113 |   }
114 |   if (method === "ws") {
115 |     const targetUrl = opts.args[0] && opts.args[0].param ? replaceUrlParam(url, opts.args[0].param) : url;
116 |     return new WebSocket(targetUrl);
                                        ^
SyntaxError: Invalid url for WebSocket /ws
@goshander goshander added the enhancement New feature or request. label Apr 9, 2024
@yusukebe
Copy link
Member

Hi @goshander

This is fixed with #2479. You can use the latest version, which includes the fix.

@goshander
Copy link
Author

goshander commented Apr 10, 2024

testClient still not work with websocket with the same error on hono v4.2.3

src/services/realtime/test.spec.ts:
120 |   if (method === "ws") {
121 |     const targetUrl = replaceUrlProtocol(
122 |       opts.args[0] && opts.args[0].param ? replaceUrlParam(url, opts.args[0].param) : url,
123 |       "ws"
124 |     );
125 |     return new WebSocket(targetUrl);
                                        ^
SyntaxError: Invalid url for WebSocket /ws
      at template-hono-ts-bun-full/node_modules/hono/dist/client/client.js:125:35

@yusukebe
Copy link
Member

@goshander

Is the URL an absolute URL? This should be an absolute URL.

@goshander
Copy link
Author

It is a testClient helper without create real web server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants