QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.84k stars 1.31k forks source link

[🐞] Qwik server crashes when entering multiple slashes at the end of a home route #6004

Closed shukklin closed 1 month ago

shukklin commented 8 months ago

Which component is affected?

Qwik Runtime

Describe the bug

If you enter several slashes at the end of the home page route and than press the Enter key, Qwik server will crash with an error:

{
    TypeError [ERR_INVALID_URL]: Invalid URL
    at __node_internal_ (https://vitejsvitedcpt7f-1uhl.w-credentialless-staticblitz.com/blitz.810981ba.js:36:5406)
    at Object.<anonymous> (https://vitejsvitedcpt7f-1uhl.w-credentialless-staticblitz.com/blitz.810981ba.js:36:4168)
    at new URL (https://vitejsvitedcpt7f-1uhl.w-credentialless-staticblitz.com/blitz.810981ba.js:48:8018)
    at eval (file:///home/projects/vitejs-vite-dcpt7f/node_modules/@builder.io/qwik/optimizer.mjs:2625:15) {
  input: '//',
  code: 'ERR_INVALID_URL'
}
image

Reproduction

https://stackblitz.com/edit/vitejs-vite-dcpt7f?file=vite.config.js

Steps to reproduce

  1. Run npm install && npm run dev.
  2. Add several slashes at the end of the home page route (for example, //).
  3. Press the enter key.
  4. Check server terminal output and you'll see an error "ERR_INVALID_URL".

System Info

System:
    OS: macOS 14.3.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 2.11 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.5.0 - ~/.nvm/versions/node/v21.5.0/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v21.5.0/bin/npm
    pnpm: 8.15.4 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 122.0.6261.112
    Safari: 17.3.1
  npmPackages:
    @builder.io/qwik: ^1.5.1 => 1.5.1 
    @builder.io/qwik-city: ^1.5.1 => 1.5.1 
    @builder.io/qwik-react: ^0.5.4 => 0.5.4 
    undici: ^6.7.0 => 6.7.0 
    vite: ^5.0.10 => 5.1.5

Additional Information

This error cannot be caught even in an layout.tsx onGet or onRequest middleware in order to somehow process it.

https://qwik.dev/docs/advanced/request-handling/#request-event

gioboa commented 5 months ago

Thanks for reporting that. We should catch this error, PRs are welcome

JerryWu1234 commented 2 months ago

Thanks for reporting that. We should catch this error, PRs are welcome

Please assign it to me.

JerryWu1234 commented 2 months ago

image I followed Atro that occurs an error hints

vanvuongngo commented 1 month ago

Hi, is this issue solved and can be closed?

gioboa commented 1 month ago

Yep, this is solved. Thanks