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

Offen
#752 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@bryanlundberg arbeitet bereits daran.

Seit 28.11.2026.

  • #753 von @bryanlundberg — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
typescript, vite
Bereich
frontend

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
TypeScript
Sterne
1.3k
Forks
193
Ø Merge
8 Std. 48 Min.
Gemergte PRs (30 T.)
21

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus solidjs/solid-router

Alle Issues in solidjs/solid-router

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.