trimPathRegex is quadratic on a long run of slashes
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 77/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js, typescript
- 領域
- frontend, performance
調査の方向性
まずルーターのソースコード内で trimPathRegex と normalizePath を見つけ、次に提供されたスラッシュが大量に含まれる入力を使って、報告された実行時間を Node で再現してください。実行時間が線形に増加するようにトリミング方法を変更し、トリミング後も期待されるパスの挙動が保たれること、およびスラッシュが100,000個のケースが短時間で完了することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 1.3k
- フォーク
- 193
- 平均マージ
- 8時間 48分
- マージ済み PR(30日)
- 21
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solidjs/solid-router のほかの issue
-
[2.0.1] Internal links do a full page load on a custom scheme (Electron app://)対応中かも @saudademjj が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 20/100
solidjs/solid-router#755 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[2.0.1] diagnostics: a request for // crashes the dev server (Invalid URL in describeInitial)対応中かも @bryanlundberg が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
solidjs/solid-router#752 ·
メンテナーはふだん 1 日以内に返信
-
liveQuery SSR: the producer of a `live()` server function is never finalized after the response ends (the `return()` queues behind a read-ahead `next()`)対応中かも @clean99 が 2 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
solidjs/solid-router#751 ·
メンテナーはふだん 1 日以内に返信
-
[2.0.1] hashHistory: link claims and useLinkState ignore the hash, so aria-current/data-active are wrong on every link対応中かも @clean99 が 9 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
solidjs/solid-router#746 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
solidjs/solid-router#736 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
solidjs/solid-router の issue をすべて見る
似ている issue
-
area:api bug good first issue priority:high
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Doezer/Questarr#1486 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:import difficulty:good-first good first issue help wanted priority:P1 roadmap size:S type:test
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Sergey-Bar/Penny#245 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
mihazs/lazysh#3377 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Approve the Cloudflare agent plugin for harness sessions対応中かも @joshtsch が今日担当しました。 オープンenhancement ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信