fix: arm the startup rebuild watchdog on the background branch too (#158) - #341
Open
ProfSynapse wants to merge 2 commits into
Open
fix: arm the startup rebuild watchdog on the background branch too (#158)#341ProfSynapse wants to merge 2 commits into
ProfSynapse wants to merge 2 commits into
Conversation
) `runStartupFullRebuild` gated both the idle watchdog and the timeout race on `isBlockingHydration`. But `onProgress` calls `updateProgress` on both branches, and that moves the hydration phase to `running`, which is not query-ready. A *background* rebuild that reported progress and then stalled therefore left `isQueryReady()` false for the rest of the session with nothing to fail it: every `waitForQueryReady()` caller burned its full idle timeout and resolved false, and the rebuild promise never settled at all. This is the same shape as the completion bug fixed in 7a5428c — the phase transition was corrected for both branches, but stall protection still covered only the blocking one. Drop the gate. The watchdog is inert until the phase actually reaches `running`, so a background rebuild that never reports progress (phase stays `idle`, which is query-ready) is unaffected. Tests inject a 50 ms idle timeout rather than waiting out the real 120 s: both new stall tests hang to a Jest timeout against the pre-fix adapter, and a third test pins the inert-while-idle behaviour so the fix cannot over-correct. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C6aSoCAS5gNoew6n9qv6DJ
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.
Addresses gap 1 of #158.
The gap
startIdleWatchdogwas gated onisBlockingHydration. ButupdateProgress()setsphase: 'running'on both branches, andrunningis not query-ready — so a stalled background rebuild leftisQueryReady()false indefinitely with nothing to fail it.This is the same shape as the bug fixed earlier today: phase completion was corrected for both branches, while stall protection still covered only the blocking one.
The fix
Both the watchdog and the
Promise.racenow arm on either branch.armIdleWatchdog()stays inert until the phase is actuallyrunning, so a background rebuild that never reports progress at all — phaseidle, which is query-ready — is unaffected. That distinction is the reason this can't just be a flag flip.Tests
Three, and the third exists to stop the fix over-correcting:
made no progresson the non-blocking branchwaitForQueryReady(10_000)settlesfalseat the injected 50 ms watchdog timeout rather than burning its own budgetidlecase stays inertPre-fix, both stall tests hang to a Jest timeout — the promise never settles, which is the defect stated as a test.
Live verification
Exercised against the real shipped bundle in headless Obsidian 1.13.7 with a 1000 ms injected timeout: rejected at 1001 ms, phase
error, and the gate resolvedfalseagainst a 30 s budget. State restored and plugin reloaded afterwards;dev:errorsclean.Still open on #158
Gap 2 —
ChatView.waitForStartupHydrationwrites the error into the overlay and returns early without hiding it, leaving no retry affordance. Not in this PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01C6aSoCAS5gNoew6n9qv6DJ
Generated by Claude Code