`light-webserver` reads each annotated screen synchronously inside the HTTP handler, stalling every other request
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 80/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
- 領域
- backend, performance
調査の方向性
Read skills/ce-brainstorm/scripts/light-webserver.js around line 1135 and compare the matching branch in skills/ce-prototype/scripts/light-webserver.js. Start by tracing the annotate document request path and how it reads and processes the HTML; reproduce the delay with the provided 32 MiB screen and concurrent /version requests. Done means the screen is served while unrelated requests stay responsive, with both copies addressed.
索引モデルが issue の本文から書いたものです。
説明
Environment
EveryInc/compound-engineering-pluginat commit122f9f90330df0b54da865e12cbecb81ffd0ae53- Node.js 24, Windows/macOS/Linux
skills/ce-brainstorm/scripts/light-webserver.jsand itsce-prototypecopy (same file content)
Summary
In annotate mode, the light-webserver reads a navigated HTML screen with fs.readFileSync from inside the async http.createServer handler, then runs annotateScreen over the full string before writing a byte. Nothing is awaited first, so the read and the string walk both run on the event-loop thread. While a large screen is being read and annotated, every other socket waits: a 3 ms /version request that normally answers in about 3 ms takes as long as the navigation's time-to-first-byte. At 32 MiB the stall is about 1.5 s; at 128 MiB about 3.3 s.
Root cause
// light-webserver.js:1129-1141, inside `if (options.annotate)` in async handleRequest()
if (req.method === "GET") {
touch()
const filePath = resolveContainedFile(options.screensDir, req, res)
if (!filePath) return
if (contentType(filePath) === CONTENT_TYPES[".html"] && isDocumentNavigation(req)) {
const renderedKey = screensChangeKey(options)
serveAnnotateDocument(req, res, annotateScreen(fs.readFileSync(filePath, "utf8"), requestOrigin(req), urlPath), renderedKey) // line 1135
return
}
...
handleRequest is async and invoked from the http.createServer callback, but there is no await before line 1135. The synchronous read and the subsequent annotateScreen pass (html.replace, isFullDocument with toLowerCase()) are linear in the screen size and block the single event loop shared by /version, /events, /wait and /annotation.
Affected code
skills/ce-brainstorm/scripts/light-webserver.js, line 1135 (annotate document branch). The same code exists at skills/ce-prototype/scripts/light-webserver.js:1135; both files are one blob at the audited commit.
Reproduction
- Create a full HTML document of the target size, for example
head -c 33554432 /dev/zero | tr '\0' 'a'wrapped in<!doctype html><html><body>...</body></html>, and place it atscreens/big.htmlunder the server root. - Start the real server in annotate mode with a fixed port:
node skills/ce-brainstorm/scripts/light-webserver.js serve \
--root <run>/root --host 127.0.0.1 --port 4180 --annotate
- Send one document navigation for
/big.html(Accept: text/html,Sec-Fetch-Dest: document) and, from the same client, four/versionrequests 3 ms apart on independent sockets. - Repeat the four requests with no navigation in flight to get the control.
Observed with Node 24 on Windows 11:
| screen | navigation TTFB | request max | requests over 50 ms | control request max |
|---|---|---|---|---|
| 1 KiB | 4.4 ms | 2.7 ms | 0 / 4 | 4.3 ms |
| 8 MiB | 94.7 ms | 71.6 ms | 2 / 4 | 3.5 ms |
| 32 MiB | 1508.9 ms | 1528.5 ms | 4 / 4 | 5.2 ms |
| 128 MiB | 3342.7 ms | 3351.8 ms | 4 / 4 | 4.3 ms |
At 32 MiB the four requests issued at +20/+40/+60/+80 ms all complete at about 1.5 s, in a single burst at the moment the handler returns; the same endpoint answers in 3鈥? ms when no navigation is in flight. A repeat run measured 1280.9 ms and 3309.8 ms TTFB for 32/128 MiB.
Expected behavior
A slow screen read should not stop unrelated clients. The handler should read asynchronously (await fs.promises.readFile) and, if the annotation pass is expensive, yield or perform it off the request path, so /version, /events and other sockets stay responsive while a page is being prepared.
Actual behavior
The handler performs the whole read and annotation synchronously before writing the first body byte. All other requests are suspended for the duration; the delay grows linearly with the screen size and the same 3 ms endpoint becomes roughly 500x slower at 32 MiB.
Suggested fix
const raw = await fs.promises.readFile(filePath, "utf8");
const body = annotateScreen(raw, requestOrigin(req), urlPath);
serveAnnotateDocument(req, res, body, renderedKey);
If annotateScreen remains a long synchronous string pass, consider chunking it or moving it to a worker for large documents.
- 主要言語
- TypeScript
- スター
- 25.6k
- フォーク
- 2.1k
- 平均マージ
- 3時間 57分
- マージ済み PR(30日)
- 170
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
EveryInc/compound-engineering-plugin のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
EveryInc/compound-engineering-plugin#2085 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
EveryInc/compound-engineering-plugin#795 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
EveryInc/compound-engineering-plugin#2083 ·
メンテナーはふだん 1 日以内に返信
-
Host support: DeepSeek Harness (dsh)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
EveryInc/compound-engineering-plugin#2072 ·
メンテナーはふだん 1 日以内に返信
-
Respect a user policy of working on the default branch (ce-commit, ce-debug, ce-worktree, ce-test-browser, ce-dogfood)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 22/100
EveryInc/compound-engineering-plugin#2071 ·
メンテナーはふだん 1 日以内に返信
EveryInc/compound-engineering-plugin の issue をすべて見る
似ている issue
-
bug impact:low Team: SecuritySolution Team:Defend Workflows v9.6.0
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
elastic/kibana#306401 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
agentes-chat/agentes-chat#927 ·
メンテナーはふだん 1 日以内に返信
-
comp/desktop P2 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NousResearch/hermes-agent#157702 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
e2e-failure ready-to-code
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
redhat-developer/rhdh-plugin-export-overlays#4794 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信