trimPathRegex is quadratic on a long run of slashes
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đá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
- 77/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, node.js, typescript
- Lĩnh vực
- frontend, performance
Hướng nghiên cứu
Trước tiên, hãy tìm trimPathRegex và normalizePath trong mã nguồn của router, sau đó tái hiện thời gian thực thi được báo cáo trong Node bằng đầu vào có nhiều dấu gạch chéo đã cung cấp. Thay đổi cách cắt để thời gian thực thi tăng tuyến tính, đồng thời xác nhận rằng việc cắt vẫn giữ nguyên hành vi đường dẫn như mong đợi và trường hợp có 100.000 dấu gạch chéo hoàn tất nhanh chóng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
In @solidjs/router 2.0.1, trimPathRegex = /^\/+|(\/)\/+$/g (used by normalizePath) backtracks quadratically when a path has a long run of slashes followed by another character. The regex engine rescans the run from every start position, then fails at $. A client-side navigation to such a path blocks the main thread.
Your Example Website or App
No app needed; the regex alone reproduces it in Node (see steps).
Steps to Reproduce the Bug or Issue
- Run in Node:
const s = "/streams" + "/".repeat(100000) + "x";
const t = performance.now();
s.replace(/^\/+|(\/)\/+$/g, "$1");
console.log(Math.round(performance.now() - t), "ms");
- It prints about 2650 ms.
- In an app using the router, navigate client-side (link or
history.pushState) to/streamsfollowed by 100,000 slashes andx: the page freezes for about 0.9 s in Chromium and Firefox and 2.9 s in WebKit. With 1,000,000 slashes it does not return within 30 s.
Expected behavior
Trimming slashes takes linear time; a long path does not freeze the page. A loop over charCodeAt from the end (or a regex without the backtracking \/+$ alternative) does it in well under 1 ms for 100,000 slashes.
Screenshots or Videos
No response
Platform
- @solidjs/router 2.0.1, solid-js 2.0.4
- Node 26.13.1
- Browsers: Chromium, Firefox and WebKit from Playwright 1.65.1
- OS: Linux
Additional context
Servers usually reject such long URLs on a direct load (e.g. HTTP 431 near 20,000 characters), so the reach is client-side links and history.pushState.
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid-router
-
[2.0.1] Internal links do a full page load on a custom scheme (Electron app://)Có thể đã có người làm @saudademjj đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 20/100
solidjs/solid-router#755 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[2.0.1] diagnostics: a request for // crashes the dev server (Invalid URL in describeInitial)Có thể đã có người làm @bryanlundberg đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
solidjs/solid-router#752 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
liveQuery SSR: the producer of a `live()` server function is never finalized after the response ends (the `return()` queues behind a read-ahead `next()`)Có thể đã có người làm @clean99 đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
solidjs/solid-router#751 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[2.0.1] hashHistory: link claims and useLinkState ignore the hash, so aria-current/data-active are wrong on every linkCó thể đã có người làm @clean99 đã nhận 9 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
solidjs/solid-router#746 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
solidjs/solid-router#736 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid-router
Issue tương tự
-
area:api bug good first issue priority:high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Doezer/Questarr#1486 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:import difficulty:good-first good first issue help wanted priority:P1 roadmap size:S type:test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Sergey-Bar/Penny#245 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mihazs/lazysh#3377 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Approve the Cloudflare agent plugin for harness sessionsCó thể đã có người làm @joshtsch đã nhận hôm nay. Đang mởenhancement ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày