Repository navigation
[PR] fix: blog panel P3 polish (content-length precheck, refresh gate, 1h cache TTL, offline wording) - #4972
Merged
Merged
Conversation
…sh gate, 1h cache TTL, neutral offline wording Four small defects from the #4906/#4908 deep review (P3 batch): - web/blog-refresh.ts: getText/getImage now precheck a declared content-length header against their size budgets BEFORE reading the body, so a hostile/lying header cannot force a 512KB text or 2MB image download (the post-read checks stay as the authority when the header is absent or lies small). - web/blog-refresh.ts: the fire-and-forget launchers (kickBlogRefresh, runBlogRefreshRound) wrap their round promise in a rejection-immune settle gate (settleRoundImmune) — an unexpected rejection inside a background TTL/coalesce round can no longer leak an unhandledRejection and kill the host process. - web/client.ts: the blog view cache now carries a timestamp and goes stale after ~1h (matching the bl.sub promise of hourly turnover); a stale hit still paints instantly and re-pulls silently in the background, re-rendering only if the blog view is still on screen. - web/i18n.ts: bl.offline no longer claims 'GitHub unreachable' — the server cannot know that; it now says the last refresh did not finish and cached content is shown (en+zh). Tests: tests/web-blog-refresh.test.ts pins all four (body-spy proves the precheck trips before arrayBuffer(); process-level unhandledRejection listener proves the gate swallows a rejecting base; TTL boundary at exactly 1h; wording pins en+zh). Refs #4957 (blog route audit trail); review thread: #4908
Contributor
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6486-pr.4972.7dd5dc6This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4972.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Contributor
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.883-master.b33052a # this exact build
npm install -g billion-context@master # always the newest merged build
|
This was referenced Oct 27, 2026
ranxianglei
pushed a commit
that referenced
this pull request
Oct 27, 2026
Follow-up merge after master advanced past c499b14 mid-resolution (#4969/#4970/#4972/#4971 blog+billing, #4544 event-loop-yield, #4678 mysql-v8-dedup, #4782 dsh-goal-subfork). Conflicts: - src/server/prepare-responses.ts: import hunk unioned again - kept this branch's fold-reconcile import line (superset of master's: adds noteBiliToolSurface/outboundBiliSurface); master's yieldToEventLoop lines from #4528 landed in all four prepare files untouched. - tests/golden/storage-render/{anthropic,chat,google,responses}.json: regenerated from the merged tree via scripts/update-storage-render-goldens.ts; output byte-identical to the previous round's regeneration (master's new commits did not change these golden conversations' outbound wire or persisted state) and differing from master only by this branch's image-rescale armed-state latch digests. Verification: no conflict markers remain; targeted suites green (golden-storage-render + fold-reconcile + issue3400-image-rescale = 109/109); typecheck clean. Full-suite verdict deferred to CI on the pushed head.
This was referenced Nov 20, 2026
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.
"## What\n\nFour small defects from the #4908 deep review's blog-route P3 batch (#4957 audit trail), fixed in one pass. All user-visible severity is P3 (polish), no behavior change on the happy path.\n\n## Changes\n\n### 1. Content-length precheck before body read —
src/web/blog-refresh.ts\ngetText/getImagenow check a declaredcontent-lengthheader against their size budgets (512KB text / 2MB image) BEFORE reading the body:\n\n- text direction: oversize declaration → round fails soft (feed.error= offline), body never downloaded;\n- image direction: oversize declaration → image silently dropped from the article (same churn as a 404), body never downloaded;\n- the header is a hint: post-read checks stay the authority when the header is absent or lies small.\n\n### 2. Rejection-immune settle gate for fire-and-forget rounds —src/web/blog-refresh.ts\nkickBlogRefresh/runBlogRefreshRound(TTL + coalesce launchers) now wrap the round promise insettleRoundImmune— a rejection inside a background round clearsinflight/roundAtand is swallowed, instead of leaking anunhandledRejectionthat kills the host process (Node default behavior).\n\n### 3. Blog cache goes stale after ~1h —src/web/client.ts\nThe panel's blog cache kept its ONE fetch for the whole tab lifetime whilebl.subpromises "约 1 小时一次" turnover. The cache now carries a timestamp (blogCacheStale, inlined into the IIFE); a stale hit still paints instantly, re-pulls silently in the background, and re-renders only if the blog view is still on screen (busy-flag prevents refresh loops).\n\n### 4. Neutral offline wording —src/web/i18n.ts\nbl.offlineno longer claims "GitHub 暂时不可达" (the server cannot know that — the pull may have failed for size/shape reasons). Now: "上次拉取未完成,显示的是缓存内容" / "Last refresh did not finish — showing cached content" (en+zh).\n\n## Tests\n\ntests/web-blog-refresh.test.ts+4 (21 total, all green):\n\n- body-spy proves the precheck trips beforearrayBuffer()for both text and image directions; lying-small header still fails soft via the post-read authority;\n- process-levelunhandledRejectionlistener proves the settle gate swallows a rejecting base and settles exactly once;\n- TTL boundary: fresh at 1h−1ms, stale at exactly 1h;\n- wording pins (en+zh).\n\nPre-fix reproduction: withsrc/webreverted, the suite fails (does not provide an export named 'blogCacheStale'+ body-spy assertions).\n\n## Verification\n\n-node --import tsx --test tests/web-blog-refresh.test.ts→ 21/21\n-tests/web-blog-route.test.ts+tests/web-i18n.test.ts+tests/web-routing.test.ts→ 36/36\n-npm run typecheckclean\n\n## config surface / scope\n\nNone — no config keys, no persistence, no wire protocol; single-module scoped (web panel + blog refresh).\n\nReview thread: https://github.com/ranxianglei/billion-context/pull/4908\nRefs #4957\n"