fix: exportAsHtml の埋め込み画像に累積バイト数上限を追加 (#354)#355
Merged
Conversation
- TOTAL_EMBED_BYTES_LIMIT = 256MB (base64 文字列長) を導入 - worker で read 完了後、累積 + 今回分が上限超過なら data URI 化を skip し 元 src を維持 (broken image と同じ graceful degradation 経路) - worker 並列で最大 K-1 個のオーバーシュートは許容 (実害なし) - test 追加: 3 img で 3 個目が skip される / 単発上限超過の境界
- JSDoc に cap 到達後の挙動 (skip + 元 src 維持) と I/O 完了順依存を追記 - 「K-1 オーバーシュート許容」コメントは誤り (check と += の間に await が 無いため JS 単スレッド性で他 worker 割り込み不可) → 事実に合わせて修正
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
exportAsHtml で埋め込む base64 画像の累積バイト数に上限 (256MB) を設け、renderer OOM リスクを graceful degradation で回避 (#354)。個別ファイル上限 (main 側 64MB) を通り抜けた画像でも、累積が V8 heap を圧迫する前に skip して元 src を維持する。
関連 Issue
closes #354
移行 Stage
変更内容
TOTAL_EMBED_BYTES_LIMIT = 256MB(base64 文字列長) をresolve-html-images.tsに追加embedHtmlImagesAsDataUriの worker で read 完了後に累積判定 → 超過ならcontinueで data URI 化を skip し元 src を維持 (broken image と同じ経路)動作確認
vitest run src/lib/resolve-html-images.test.ts— 19/19 pass (新規 2 件を含む)vitest run— 2578/2578 pass (前 main 2576 + 新規 2)tsc -p tsconfig.web.json --noEmit/tsc -p tsconfig.node.json --noEmitclean検証エビデンス
リスク分類
tier: medium — 一般的な変更 (単一 IPC でも security 境界でもないが、renderer heap 保護目的の防御コードのため medium 相当で codex security を実行)
実行した検証
./node_modules/.bin/vitest run./node_modules/.bin/vitest run src/lib/resolve-html-images.test.ts./node_modules/.bin/tsc -p tsconfig.web.json --noEmit./node_modules/.bin/tsc -p tsconfig.node.json --noEmit./node_modules/.bin/biome check src/lib/resolve-html-images.ts src/lib/resolve-html-images.test.tsレビュー指摘と対応
/simplify (4 angle 並列):
BoundedByteBudget抽象化 → SKIP (単一 caller で hard-coding 妥当、agent 自身も同結論)TOTAL_EMBED_BYTES_LIMIT = EMBED_CONCURRENCY * MAX_READ_FILE_BYTESderivation → SKIP (renderer heap 予算と main peak 保護は別関心、意図的に drift 可能)/code-review medium (8 finder → verify):
456866e— check と+=間 await 無しで JS 単スレッド性により overshoot 不可能456866e— cap 挙動を JSDoc に追記codex-review security: PASS (0 findings)
追跡先
なし
Draft 判定
456866eで解消済、追跡 issue 化する未対応残なし