Repository navigation
[PR] fix: web overview rides the persist store singleton instead of opening a second SessionStore - #5002
Merged
Conversation
The web module (GET /__bili/overview and friends) kept its own lazily constructed SessionStore. In unified storage modes that constructor re-runs the full open-time path - integrity check, lockfile, migration pass, WAL checkpoint - on the live main thread, so a healthy proxy stalled ~20s on its first overview request with a ~900MiB database (v0.1.208). - sessions-data.ts: drop the private diskStore/getDiskStore; every call site now rides persist.getStore() (the instance the engine already opened at boot) - persist.ts: add _resetStoreForTest() (close + drop the singleton) so the web test reset keeps its re-resolve-env contract without owning a second store - _resetDiskCacheForTest() funnels through _resetStoreForTest() - tests/issue4990-web-single-store.test.ts: regression test covering both gate directions (rides the engine instance, no second open; disabled- store file-walk degradation). Verified to fail on pre-fix source. Behavior change (BILI_PERSIST=0 / persist.enabled=false only): overview and session detail previously used a locally enabled store, which listed row-only sessions from the index in unified modes. They now ride the disabled engine store and fall back to the legacy JSON file walk - envelope-bearing sessions are still listed, row-only sessions are not. Persistence-enabled paths have zero behavior change. Related: #4609, #4643 (open-time integrity check cost family)
Contributor
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6887-pr.5002.163545eThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5002.tgz
npm install -g packageInstall instructions are refreshed on each push. |
added 2 commits
October 28, 2026 03:35
…sidecar harness (#4990) The harness injects a disabled SessionStore pointing at <run>/sessions via _setStoreForTest but never created that dir. Before #4990 the web read surface ignored the singleton (it built its own store on the default layout, which the harness did create), so this stayed hidden. Now the web rides getStore(), walks the injected dir, hits ENOENT, and stays loud per the #1937 pristine gate (data root holds a non-infra 'sessions' entry) -> /__bili/sessions 500s -> the sessionIds() helper crashed on .map of undefined. Two test shards' worth of red across ubuntu/windows. - create <run>/sessions so the injected state is production-plausible (in production the engine store's dir is created by the open path or is the pristine default layout; a custom dir beside a non-pristine data root cannot occur outside injection) - sessionIds() now asserts the list shape and dumps the body instead of dying with an opaque TypeError when the endpoint errors Server behavior unchanged: the #1937 loudness contract for suspicious missing dirs is intact.
Contributor
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.922-master.7553b41 # this exact build
npm install -g billion-context@master # always the newest merged build
|
ranxianglei
pushed a commit
to Zhishulo/billion-context
that referenced
this pull request
Oct 31, 2026
…i#4942) Resolution notes: - src/persist.ts single hunk: both sides inserted functions at the same spot. Kept ours' restoreBlockContents extraction (from the ranxianglei#5198 era) as its own function, dropped theirs' duplicate 'function buildSession' line (ours' refactored version below it already calls restoreBlockContents), and kept theirs' new export recordToLegacyView immediately above buildSession. The legacyLoad wiring (persist.ts:512) came through auto-merge intact. - src/web/sessions-data.ts: took d-4987's async load shape mapped onto the current process singleton: 'await getStore().loadAsync(id)' (the branch-local getDiskStore() local is obsolete since ranxianglei#5002 unified the store). - store.ts/sessions-data.ts auto-merge verified by full tsc parse.
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.
Closes #4990
What & why
GET /__bili/overview(and the other web read surfaces) kept their own lazily constructedSessionStore(getDiskStore()insrc/web/sessions-data.ts). In unified storage modes theSessionStoreconstructor re-runs the full open-time path — integrity check, lockfile write, migration pass, WAL checkpoint — on the live main thread. A healthy pi-native proxy therefore stalled ~20s on its FIRST overview request with a ~900MiB database (measured 19,910ms synchronous quick_check on v0.1.208).The engine already owns a shared store instance (
persist.getStore(), constructed at boot, same dir/config/mode). This fix makes every web read site ride that singleton: one store per process, no second open, no duplicated integrity check / migration / checkpoint on the overview path.Changes
src/web/sessions-data.ts: drop the privatediskStore/getDiskStore(); all call sites usegetStore().src/persist.ts: new_resetStoreForTest()test hook (close + drop the singleton) so the web test reset keeps its re-resolve-env contract without owning a second store._resetDiskCacheForTest()funnels through_resetStoreForTest().tests/issue4990-web-single-store.test.ts, both gate directions (Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617):BILI_SESSIONS_DIRserves the list and overview; structural assertions prove noindex.dbis ever opened against the env dir and zero file-walk decodes happen;BILI_PERSIST=0shape) degrades to the legacy file walk — envelope-bearing sessions still listed, row-only sessions drop, no crash.Behavior change (disclosed)
Applies ONLY when persistence is disabled (
BILI_PERSIST=0orpersist.enabled: false):Persistence-enabled paths (the default): zero behavior change — same dir, same config, same mode; the web surface was read-only already and simply stops opening a second connection.
Complements #4852 (merged, post-v0.1.208): the verdict cache made the FIRST open cheap; this removes the SECOND open entirely (it previously still paid connection + lockfile rewrite + migration pass + WAL checkpoint).
Related: #4609, #4643 (open-time integrity check cost family).
Verification
npm run typecheckgreen on the pushed head.