Skip to content

fix(ratewise): 移植導覽 case-3 有界網路 fallback 至 main#456

Merged
s123104 merged 3 commits into
mainfrom
fix/port426
Jun 27, 2026
Merged

fix(ratewise): 移植導覽 case-3 有界網路 fallback 至 main#456
s123104 merged 3 commits into
mainfrom
fix/port426

Conversation

@s123104

@s123104 s123104 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

摘要

回補生產缺口:PR #426「導覽 case-3 有界網路 fallback」當初合進 chore/ratewise-production-governance 分支而非 main(已用 git merge-base --is-ancestor 驗證非 main 祖先;origin/main:sw.tsNAVIGATION_FETCH_TIMEOUT_MS)。本 PR 將其意圖忠實移植至 main。

由並行 Cursor 子代理(composer-2.5-fast,獨立 worktree)完成移植。

變更(apps/ratewise/src/sw.ts)

  • 新增 NAVIGATION_FETCH_TIMEOUT_MS = 8000
  • case-3(html-cache miss 且 precache miss):Promise.race([networkFetch, 8s timeout]),逾時改回 resolveNavigationFallback()(offline shell),避免連線掛住造成無限白屏。
  • 逾時後以 event.waitUntil(networkFetch…) 保留 in-flight fetch,成功仍寫入 html-cache(下次可命中)。
  • precache miss 後套用;不重新引入舊版全域 3 秒逾時。
  • 補 case-2/case-3 行為測試 + 禁止舊版全域 timeout 的防回歸斷言。

Test plan

  • vitest run src/__tests__/sw.test.ts → 36 passed
  • tsc --noEmit → exit 0
  • diff 最小、KISS、無多餘註解

🤖 Generated with Claude Code

- precache miss 時以 8 秒 Promise.race 限制網路等待,逾時回 offline shell
- 逾時後以 event.waitUntil 保留 in-flight fetch,成功仍寫入 html-cache
- 僅在 precache miss 後套用,不重新引入全域 3 秒逾時
- 補 case-2/case-3 行為測試與防回歸斷言

測試:vitest sw.test.ts 36 項通過、tsc --noEmit 通過
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bc7e4c18d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1 to +3
---
'@app/ratewise': patch
---

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 補上 002 稽核紀錄

此 commit 新增 changeset 與 apps/ratewise 程式碼,但檢查 git diff-tree 後沒有包含 docs/dev/002_development_reward_penalty_log.md/workspace/app/AGENTS.mdAGT-LOG-01 與 Phase 4 明定每次 git commit 前必須更新 002(含本次分數變化與累計總分);缺少該檔會讓這次修復無法被獎懲/稽核 log 追蹤,請在同一變更補上符合 002 模板的條目與總分更新。

Useful? React with 👍 / 👎.

- 網路先成功時 clearTimeout,避免逾時計時器稍後 reject 成 unhandled rejection
- 補網路成功回傳 network response 與晚成功仍寫入 html-cache 的測試

測試:sw.test.ts 38 項通過、tsc 通過
@github-actions

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

- 將 mock 方法擷取為區域變數後再斷言,消除 @typescript-eslint/unbound-method

測試:sw.test.ts 通過、pnpm lint 通過、tsc 通過
@github-actions

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

@s123104 s123104 merged commit b615b4a into main Jun 27, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant