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

Đang mở
#752 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@bryanlundberg đang làm issue này rồi.

Từ ngày 28/11/2026.

  • #753 của @bryanlundberg — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript, vite
Lĩnh vực
frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
1.3k
Fork
193
Merge trung bình
8 giờ 48 phút
Pull request đã merge (30 ngày)
21

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của solidjs/solid-router

Tất cả issue của solidjs/solid-router

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.