GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — fix: #101 OGP fetch に AbortController を実装して cancel 可能化 by ymnao · Pull Request #137 · ymnao/scripta Conversation
Owner
概要OGP fetch の cancel 経路を実装し、文書切替時に in-flight な fetch を中断可能にする。さらに複数 view が同じ URL の loading entry を共有する状況下で起きる膠着・誤 abort・stuck race を順次解消した。 関連 IssueCloses #101 移行 Stage
変更内容中核機能 (commit d0d58da)
/simplify レビュー反映 (commit 72a8571)
レビュー指摘 P2-1 / P2-2 / P3 反映 (commit 447a9ca)
追加レビュー反映 (commit de48ae1)
完了通知の broadcast 統一 (commit c3f2d72)
動作確認
補足実 Electron e2e (
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions- httpFetch に signal?: AbortSignal を追加。pre-aborted は即時 reject、in-flight 中の abort は req.destroy で発火し既存の close/error 経路で reject に合流する - ogp.ts に URL→Set<AbortController> の in-flight Map と cancelOgpFetch を追加。 fetchOgpImpl は controller を 1 つ作って Map に register、finally で必ず unregister - ogp:cancel IPC handler を追加し preload で window.api.ogpCancel(url) として公開、 renderer 側ラッパ cancelOgpFetch を src/lib/commands.ts に追加 - LinkCardDecorationPlugin.destroy() で fetchingUrls 全件に対し cancelOgpFetch を発行。 AbortError catch では cache を error 状態にせず entry を削除して次回 retry を許可 - 文書切替は AppLayout で editorKey が増分されて MarkdownEditor が unmount するため、 plugin destroy が必ず発火する → 別途 hook で cancel する必要は無い - e2e / vitest の api mock に ogpCancel を追加 Closes #101 …ontroller> 単純化
/simplify の指摘反映:
- ErrorKind に "ABORTED" を追加(src/types/errors.ts, src/lib/errors.ts)。serializeIpcError
は err.name を IPC 越しに保たないため、renderer 側の err.name === "AbortError" 検出は
デッドコードだった。fetchOgpImpl で AbortError → StructuredError("ABORTED") へ変換し、
renderer は getErrorKind(err) === "ABORTED" で判別する
- inFlight Map を Set<AbortController> から AbortController 単一値へ簡素化。register/
unregister helpers を削除し、unregister は identity check(後発上書き時の race を許容)
- fetchOgpImpl の test-only signal? 引数を削除。テストは cancelOgpFetch 経路で同等の
カバレッジを確保
- link-cards destroy() の snapshot-then-clear を単純な for...of + clear() に
- 冗長な justification コメントを 1 行化
- fetchWithRedirects の signal.aborted 早期 throw を削除(httpFetch の pre-aborted で十分)
- link-cards.test の view.destroy() 後の mounted.pop() を削除(afterEach の destroy は
idempotent)
…ort 対策 レビュー指摘 (P2-1 / P2-2 / P3) を反映: P2-2: cancel が他 view の後発 request を誤 abort する問題 - main: inFlight Map のキーを URL → requestId に変更 - IPC: ogp:fetch(requestId, url) / ogp:cancel(requestId) - preload + commands.ts + e2e mock も requestId シグネチャへ更新 - renderer: 各 fetch ごとに crypto.randomUUID() を発行し、destroy 時は自身の requestId だけを cancel する P2-1: ABORTED catch が共有 loading entry を消して他 view の card を空にする問題 - renderer の ABORTED catch では ogpCache を触らない(loading entry は他 plugin が完了待ち中の可能性があるため) - 開始者が cancel された等で stuck になった loading 用に LOADING_STALE_MS = 60s を導入。古い loading は次の update で別 plugin が re-fetch する P3: DNS / pinSafeLookup 中の abort が効かず最大 5s 残る問題 - fetchWithRedirects のループ頭で signal.aborted チェックを復活(少なくとも次の hop の DNS には進まない、文書切替時の即時性を確保) テスト: - requestId-scoped cancel で他 req に影響しないことを担保するユニットテスト追加 - link-cards.test を requestId シグネチャへ更新 P2 (新しい): cancel 後の stuck loading で active view が無期限に膠着する問題 - CacheEntry.loading に owner requestId を持たせる - ABORTED catch では「自分が開始した loading」だけを ogpCache.delete し、他 view には影響させない - delete 直後に window.dispatchEvent で scripta:ogp-cache-invalidated を broadcast、 生存中の他 plugin が listener 経由で view.dispatch を発火 → fetchMissingOgp で 即時 re-fetch する。これにより「LOADING_STALE_MS=60s 待ち」が hot path から外れ、 fallback として残るだけになる - LinkCardDecorationPlugin の constructor で listener 登録、destroy で removeEventListener P3: DNS lookup 中の abort が効かず最大 REQUEST_TIMEOUT_MS 残る問題 - pinSafeLookup / lookupWithTimeout に optional signal を追加 - Promise.race の参加者として「signal abort」を加え、DNS 待ち中の cancel に即応 - ogp.ts が pinSafeLookup(host, timeout, signal) で signal を伝播 - ogp.ts の catch は AbortError instance に加え controller.signal.aborted も判定し、 DNS-abort 経由(カスタム ABORT_ERR エラー)も ABORTED kind へ変換 テスト: - ssrf-guard.test に「pre-aborted signal で即時 reject」「mid-DNS-lookup abort」を追加 - link-cards.test に「ABORTED catch が cache 削除 + broadcast を発火する」を追加 loading entry を plugin 間で共有しているのに通知が開始者ローカルに閉じている問題を
解消するため、ABORTED だけでなく loaded / error 完了でも cache invalidation を broadcast
する。また destroy 後に fetch が成功で resolve する race でも cache を必ず更新する。
P2-A: 成功完了の通知が開始元 view にしか届かない
- 旧コードは then() で `view.dispatch({})` のみ呼んでおり、loading を共有している
他 view (同 URL を含む別 EditorView) には通知されなかった → 他 view は次の編集 /
viewport change まで空カードのまま
- 完了経路 (loaded / error) で broadcastOgpCacheInvalidated を発火し、生存中の他
plugin の listener から view.dispatch を再発火させる(abort と同じ機構)
- 自身の view 再描画も listener 経由に統一(重複した明示 view.dispatch を削除)
P2-B: destroy 後の成功 resolve で loading が更新されない
- 旧 then() は `if (this.destroyed) return` を cache 更新より前に置いていた → cancel
と通信完了の race で成功が勝つと loading のまま放置され、待機 view が膠着
- cache 更新と broadcast は destroyed フラグに関係なく実行する。listener 側の
destroyed 判定で自分の view へは dispatch しない(他 view への通知だけ走る)
合わせて broadcastOgpCacheInvalidated ヘルパを抽出し、3 経路で共有。
テスト:
- successful fetch が broadcast を発火することを検証
- destroy 後の late-success でも broadcast が走ることを検証
- 既存テストの URL を test ごとにユニーク化(モジュールスコープな ogpCache の
汚染防止)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
ymnao
added a commit
that referenced
this pull request
- Fixed にバグ修正クラスタをロールアップ追記 (#116 #117 #120 #124 #130 #131 #132 #134 #135 #136 #137) - Added に手動アップデートチェック (#98 → #138) を追記 - Dependencies を Phase α 反映の実バージョンに更新 (electron 42.3.3 / biome 2.4.16 / zustand 5.0.14 / js-yaml 4.2.0 / dompurify 3.4.8 / marked 18.0.4 / lucide-react 1.17.0 / @codemirror/view 6.43.0 / vite 8.0.14 / vitest 4.1.7) - リリース日を _(unreleased)_ に、旧リポ表記を scripta-tauri (private) に、 footer URL を ymnao/scripta に修正 Co-Authored-By: Claude Opus 4.8 <[email protected]>
ymnao
added a commit
that referenced
this pull request
* release: v0.2.0 - package.json:version 0.0.0 → 0.2.0 - CHANGELOG.md 新設(旧 Tauri 版から Electron への完全書き直し版として Added / Changed / Fixed / Dependencies / Security / 既知の制限 を記載) closes #27 * docs: v0.2.0 リリース運用注釈と README の表現を release-ready に更新 レビュー指摘反映: - README.md: "v0.2.0 を予定" / "リリース後 ... 取得できる予定" を リリース後にも valid な表現へ書き換え(merge → tag push 後に Releases ページが publish される前提) - docs/parity-checklist.md § 12: 「必須 4 項目は tag push 前に 手動検証で pass させ、検証ログを Release Notes に追記する」 というリリース運用を冒頭に明示 * docs: CHANGELOG リリース日と parity-checklist リリース運用を実態に合わせる レビュー指摘反映: - CHANGELOG.md: リリース日を 2026-05-13 → 2026-05-14 (publish/tag 日に揃える) - docs/parity-checklist.md § 12: release.yml が tag push 後に draft Release を `--generate-notes` で自動生成する流れに合わせ、 「Release Notes 追記 → tag push」を「tag push → draft 自動生成 → 生成された draft に検証ログ追記 → publish」の正しい順序へ修正 * docs: CHANGELOG を v0.2.0 リリース内容に更新 - Fixed にバグ修正クラスタをロールアップ追記 (#116 #117 #120 #124 #130 #131 #132 #134 #135 #136 #137) - Added に手動アップデートチェック (#98 → #138) を追記 - Dependencies を Phase α 反映の実バージョンに更新 (electron 42.3.3 / biome 2.4.16 / zustand 5.0.14 / js-yaml 4.2.0 / dompurify 3.4.8 / marked 18.0.4 / lucide-react 1.17.0 / @codemirror/view 6.43.0 / vite 8.0.14 / vitest 4.1.7) - リリース日を _(unreleased)_ に、旧リポ表記を scripta-tauri (private) に、 footer URL を ymnao/scripta に修正 Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewers
Copilot code review
Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Uh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. fix: OGP fetch に AbortController を実装して cancel 可能化Uh oh!
There was an error while loading. Please reload this page. 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. |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |