Skip to content

Drain queued SQLite replies before faulting after a main-loop stall - #26444

Merged
nwparker merged 3 commits into
mainfrom
nwparker/fix-windows-writer-stall-budget
Oct 8, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/fix-windows-writer-stall-budget

Conversation

@nwparker

@nwparker nwparker commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​27 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13

ELI5

A stalled Electron main loop can report that SQLite saving timed out even though the worker already queued a successful reply. Let that reply arrive before declaring the writer failed.

What Changed

The final deadline check now waits across two poll turns instead of one. Clearing or rearming the deadline cancels the pending check at either stage. The existing timeout values and finite power/stall grace limit stay intact.

A new regression covers a reply delivered after the first poll; the original implementation fails it. Existing deadline tests drain both turns and retain their timeout, grace, cleanup, and resume assertions. The hidden Electron fixture reports its current phase and worker/reply counters on failure, without paths or profile data. Its original two-second test budget is retained.

Why

Windows packaging in #26425 timed out the existing stall probe. Increasing the probe budget did not fix the failure: it still faulted while running the deliberate stalls. Giving the already-queued reply another poll turn addresses the ordering race while a hung worker still fails within the existing bounded deadline policy.

Linked Issue

Internal maintainer-requested CI fix. Follow-up to #26425; the maintainer exception applies.

Visual Proof

N/A — this changes SQLite deadline handling and a hidden Electron regression fixture, with no direct UI or interaction change.

Testing

  • The new late-reply regression fails against the original deadline implementation.
  • 69 writer tests pass locally (deadlines, shutdown, sleep/resume, protocol faults, capacity errors, worker authority, and real Electron stalls) with ORCA_BACKGROUND_LAUNCH=1, including four stalls beyond the unchanged two-second deadline.
  • Existing timeout, finite grace, cleanup, and resume assertions retained.
  • pnpm tc:node and changed-code quality pass locally.
  • Windows packaging on Add saved force-delete preference to workspace deletion menu #26425 validates this same fix on Windows; both PRs are checked before merge.

Review

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer material copied.

Checklist

  • Small and focused
  • User-facing impact, mechanism, and rationale explained
  • Visual proof marked N/A with reason
  • Self-reviewed
  • Cross-platform and SSH persistence impact considered
  • Relevant tests, typecheck, and changed-code lint passed locally; CI covers Windows

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 59435b2e-c995-46ab-bb3c-5ebcd878325d
📥 Commits

Reviewing files that changed from the base of the PR and between fa4ec7e and 2c9d2d7.

📒 Files selected for processing (4)
  • src/main/persistence/profile-state/profile-state-writer-close.test.ts
  • src/main/persistence/profile-state/profile-state-writer-deadline.test.ts
  • src/main/persistence/profile-state/profile-state-writer-deadline.ts
  • src/main/persistence/profile-state/profile-state-writer-electron-fixture.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The deadline expiry path now waits for a second event-loop poll before it clears the active deadline and calls onTimeout. Deadline tests wait through both polls and verify that a queued clear prevents timeout delivery. The close-timeout test adds a poll before its assertions. The Electron fixture adds phase, queued-reply, and worker-start details to failure logs.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 2c9d2

The additional poll allows queued replies another turn to drain, while clearing or rearming cancels the pending timeout check. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: allowing queued SQLite replies to arrive before faulting after a main-loop stall.
Description check ✅ Passed The description is mostly complete and covers the problem, mechanism, rationale, linked issue context, testing, visual proof, review boundaries, and checklist. The Review and Notes sections are not fi…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker nwparker changed the title Stabilize Windows Electron writer stall probe startup Drain queued SQLite replies before faulting after a main-loop stall Oct 8, 2026
@nwparker
nwparker merged commit 46ef7c4 into main Oct 8, 2026
42 checks passed
Fanzzzd added a commit to Fanzzzd/orca that referenced this pull request Oct 9, 2026
Picks up upstream's profile-state writer fixes (stablyai#25318, stablyai#26444, stablyai#26447).
Brings the offscreen-page file drop, iroh SAFETY/device-grant cleanups and
extension e2e typing in line with their current PR branches.

Claude-Session: https://claude.ai/code/session_01DvNJ16LEPYmdEkpQWtDL7n
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