fix: preserve persisted cache crash diagnostics#161
Conversation
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
📝 WalkthroughWalkthroughAdds a ChildStoreError utility and helpers to validate directories, create persisted child caches with preserved causes and structured context, and updates the child-store manager to use these utilities instead of inline persisted/runWithOwner logic. Changes
Sequence Diagram(s)sequenceDiagram
participant Manager as Manager (ensureChild)
participant Validator as validateChildStoreDirectory
participant PersistFactory as Persist / persisted / custom persist
participant Solid as Solid Owner (runWithOwner)
participant ErrorUtil as createChildStorePersistedCacheError / ChildStoreError
rect rgba(200,220,255,0.5)
Manager->>Validator: validate directory
Validator-->>Manager: directory ok / throws ChildStoreError
end
rect rgba(220,255,200,0.5)
Manager->>PersistFactory: build persist target (storage/key)
Manager->>Solid: runWithOwner(callback)
Solid->>PersistFactory: invoke persisted factory
PersistFactory-->>Solid: returns persisted cache OR throws
Solid-->>Manager: returns cache OR surfaces error (may be undefined)
end
rect rgba(255,220,200,0.5)
alt persisted step throws or owner surfaces error
Manager->>ErrorUtil: createChildStorePersistedCacheError(messageKey, context, cause)
ErrorUtil-->>Manager: throws ChildStoreError (with context + cause)
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
8185142 to
9435849
Compare
Astro-Han
left a comment
There was a problem hiding this comment.
Nitpick pass. Logic is sound and CI is green; comments below are P2/P3 polish.
9435849 to
969e304
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/app/src/context/global-sync/child-store.ts`:
- Around line 133-168: The current code calls
vcsCache.set/metaCache.set/iconCache.set as each createPersistedChildCache
returns, which can expose partially-initialized state if a later
createPersistedChildCache throws; modify ensureChild() to first call
createPersistedChildCache for vcs, project (meta) and icon and store their
returned tuples in local variables (e.g., vcsTuple, metaTuple, iconTuple)
without mutating vcsCache/metaCache/iconCache or children/disposers, then after
all three succeed call vcsCache.set(directory,...),
metaCache.set(directory,...), iconCache.set(directory,...) and only then
register children[directory] and push to disposers; also ensure that if any
createPersistedChildCache throws you clean up any already-created stores
(dispose or rollback) before rethrowing to avoid leaks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2b2b7626-5fa5-4d10-bedc-a9dea073828b
📒 Files selected for processing (4)
packages/app/src/context/global-sync/child-store-error.test.tspackages/app/src/context/global-sync/child-store-error.tspackages/app/src/context/global-sync/child-store.test.tspackages/app/src/context/global-sync/child-store.ts
969e304 to
8f4c148
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/app/src/context/global-sync/child-store.ts (1)
133-164:⚠️ Potential issue | 🟠 MajorRoll back the earlier persisted caches when later setup fails.
If
projectoriconcreation throws, the earliercreatePersistedChildCache(...)calls have already bound their persistence work toinput.owner, but this path has no rollback/dispose step for those partial successes. The cache maps stay empty now, but retries can still accumulate orphaned persisted listeners/writers for the sameworkspace:*keys. Please create the three persisted caches under a disposable per-directory root and tear that root down on failure before rethrowing.#!/bin/bash set -euo pipefail echo "== child-store setup path ==" fd '^child-store\.ts$' packages/app/src/context/global-sync -x sed -n '130,230p' {} echo echo "== persisted factory return contract ==" fd '^persist\.ts$' packages/app/src -x sed -n '1,80p' {} fd '^persist\.ts$' packages/app/src -x sed -n '485,620p' {}Expected result:
ensureChild()createsvcs,project, andiconsequentially before any directory-scoped disposer is registered, whilepersisted(...)returns only the 4-tuple and does not give this call site a way to tear down already-created partial successes. As per coding guidelines "Always prefercreateStoreover multiplecreateSignalcalls in SolidJS".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/app/src/context/global-sync/child-store.ts` around lines 133 - 164, The createPersistedChildCache calls in ensureChild() (creating vcs, meta, icon) can partially succeed and leave persisted listeners bound to input.owner; wrap these three creates in a directory-scoped disposable root (e.g. create a per-directory disposer or CompositeDisposable) so that if any createPersistedChildCache (vcs, project, icon) throws you call that disposer to tear down previously-created caches (unbind persistence for Persist.workspace entries) before rethrowing; update ensureChild() to register the successful directory-scoped disposer with the parent only after all three caches are created, and reference the existing symbols createPersistedChildCache, Persist.workspace, input.owner, and createStore to locate the changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@packages/app/src/context/global-sync/child-store.ts`:
- Around line 133-164: The createPersistedChildCache calls in ensureChild()
(creating vcs, meta, icon) can partially succeed and leave persisted listeners
bound to input.owner; wrap these three creates in a directory-scoped disposable
root (e.g. create a per-directory disposer or CompositeDisposable) so that if
any createPersistedChildCache (vcs, project, icon) throws you call that disposer
to tear down previously-created caches (unbind persistence for Persist.workspace
entries) before rethrowing; update ensureChild() to register the successful
directory-scoped disposer with the parent only after all three caches are
created, and reference the existing symbols createPersistedChildCache,
Persist.workspace, input.owner, and createStore to locate the changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5363dbe8-3a24-4dab-8bf2-9b1572c7d68b
📒 Files selected for processing (4)
packages/app/src/context/global-sync/child-store-error.test.tspackages/app/src/context/global-sync/child-store-error.tspackages/app/src/context/global-sync/child-store.test.tspackages/app/src/context/global-sync/child-store.ts
Summary
Preserve the original cause and child-store cache context when workspace persisted cache creation fails. Invalid runtime workspace directory input now fails before persistence setup instead of continuing into
Persist.workspace(...).Why
Closes #156. The packaged app could show only
Failed to create persisted cache, which hid the synchronous exception, storage file, key, cache kind, and workspace directory. The fix keeps the failure at the child-store layer and does not change storage namespace behavior.This intentionally turns empty workspace directories into explicit child-store errors too. Previously
ensureChild("")only logged and continued into a fallback workspace cache path, which masked bad upstream input.Related Issue
Closes #156
How To Verify
Screenshots or Recordings
Not applicable. No visible UI layout change.
Checklist
dev, and my PR title and commit messages use Conventional Commits in EnglishSummary by CodeRabbit
New Features
Bug Fixes
Tests