[2.0.1] diagnostics: a request for // crashes the dev server (Invalid URL in describeInitial)

Open
#752 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@bryanlundberg is already working on this.

Since Nov 28, 2026.

  • #753 by @bryanlundberg — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript, vite
Domain
frontend

Research direction

Start with describeInitial and the related URL construction call sites in src/routers/factory.tsx, then inspect the router tests for the appropriate location to add a regression case. Reproduce with a development server configured for SSR and diagnostics, or exercise the affected code through the existing test harness. The work is done when a request path beginning with // no longer throws an uncaught Invalid URL error and the server continues running.

Written by the indexing model from the issue text.

Description

Describe the bug

With @solidjs/vite-plugin's diagnostics: true, a page request whose path is // crashes the whole Vite dev server with an uncaught TypeError: Invalid URL.

The router declares the initial route for attribution through OBSERVE.attribution.withOrigin(describeInitial(...)). describeInitial resolves the location with new URL(to(), mockBase). For // that's a protocol-relative URL with an empty host, so the constructor throws. The getter is read in settleRender, outside any try/catch, so the dev process exits.

The same request answers 200 with diagnostics: false, and in the production build (node dist/server/node.js).

Versions: @solidjs/router 2.0.1 (the code is unchanged on main), solid-js 2.0.4, @solidjs/web 2.0.4, @solidjs/vite-plugin 3.0.1, vite 8.4.0.

Steps to Reproduce the Bug or Issue
  1. Start mode with ssr: true and diagnostics: true, Solid Router 2 mounted in App; pnpm dev
  2. curl 'http://localhost:3000//'
  3. The dev server exits:
TypeError: Invalid URL
    at new URL (node:internal/url:819:25)
    at pathname (@solidjs/router/dist/routers/factory.jsx:104:28)
    at Object.<Routes routerState={routerState} branches={branches}/> (@solidjs/router/dist/routers/factory.jsx:112:37)
    at Object.settle (@solidjs/web/dist/server.dev.js:357:19)
    ...
  code: 'ERR_INVALID_URL',
  input: '//',
  base: 'http://sr'
Expected behavior

The request renders (or 404s) and the dev server keeps running.

Platform
  • OS: Linux
  • Browser: any (also plain curl)
  • Node: 24.14.1
Additional context

Other new URL(…, mockBase) calls in factory.tsx may have the same problem for paths starting with //, e.g. the navigation attribution's pathname.

Workaround: a start middleware that redirects paths with repeated slashes to their single-slash form.

Dominant language
TypeScript
Stars
1.3k
Forks
193
Avg merge
8h 48m
Merged PRs (30d)
21

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from solidjs/solid-router

All issues in solidjs/solid-router

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.