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

Try to connect to ws before server initialization: "Must provide a proper URL as Target" #3013

Open
WerdoxDev opened this issue Jan 21, 2025 · 0 comments

Comments

@WerdoxDev
Copy link

WerdoxDev commented Jan 21, 2025

Environment

just the exact codesandbox template using nodejs.

Reproduction

You can use this code in the browser to keep trying to connect to the websocket and then run the server in the codesandbox.

Here is the code:

setInterval(() => {const ws = new WebSocket("https://pp9zzy-3000.csb.app")}, 2000);
//          I'm not sure if the url will be exactly this or not ^

and the codesandbox:
https://codesandbox.io/p/github/nitrojs/nitro/csb-pp9zzy/draft/compassionate-wiles

Steps:

  • run the code so it keeps trying to connect to the websocket,
  • run the nitro server with "npm run dev" in codesandbox
  • you will see an error saying "Must provide a proper URL as Target"

Describe the bug

The bug only happens when you got clients already trying to connect to the websocket before the server is even running.
It won't happen if the server is run first and then clients start to connect.

Additional context

No response

Logs

error: Must provide a proper URL as target
      at <anonymous> (E:\JS\huginn-monorepo\node_modules\httpxy\dist\index.mjs:539:9)
      at <anonymous> (E:\JS\huginn-monorepo\node_modules\nitropack\dist\core\index.mjs:2457:7)
      at emit (node:events:331:22)
      at fetch (node:http:589:24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant