Skip to content

Prevent mailbox refresh failures under load - #315

Merged
huacnlee merged 3 commits into
mainfrom
fix/backend-request-backpressure
Sep 30, 2026
Merged

huacnlee merged 3 commits into
mainfrom
fix/backend-request-backpressure

Conversation

@huacnlee

@huacnlee huacnlee commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Opening several watched mailboxes could reject otherwise valid work in two places: the UI failed the 65th pending RPC immediately, and internal MIME/cache/large-JSON transfers all began at once despite the backend's eight-upload, 128 MiB reservation limits. This fixes #304 and fixes #250 together without increasing either backend limit.

Accepted RPCs now wait in a FIFO behind the existing 64-frame window. Their deadline starts when sent, and a callback that submits more work joins the tail. Queued requests can be cancelled without dispatching them; an already-sent request keeps its slot until its reply or connection failure.

One upload queue belongs to each backend connection and accounts for both declared bytes and slots. Parse, body-cache and large-request uploads share it. A failed or cancelled transfer holds its reservation until discard answers, including when ordinary traffic has filled the RPC window. Unconfirmed discard stops the connection rather than assuming its bytes were released. Disconnect and shutdown settle waiting transfers, and replies from a stopped connection cannot revive them. Cancellation can also withdraw the final domain operation while it is still queued, so staged bytes do not turn into a cancelled write.

The existing byte-string encoding, chunk limits, per-operation size limits and Rust API remain unchanged. No provider HTTP retry policy or unrelated account behavior is changed.

Verification

  • All 14 GitHub CI jobs passed on final head 6e3c367, including standalone backend/app gates and production packaging on Linux, macOS and Windows, native credential contracts, and released/unreleased backend compatibility.
  • Native Rust suite passed: 566 unit tests (11 explicitly ignored), 33 CLI tests, and all remaining integration/doc-test targets. No Rust source or API contract changes.
  • Full JavaScript suite passed. The new production-bridge tests cover 225-request bursts, FIFO/reentrant admission, immutable payload snapshots, queued and active cancellation, the final uploaded-operation cancellation race, byte reservations, delayed discard, failed cleanup, disconnect/reconnect and callback exceptions during shutdown.
  • Final Qt 6.11.2 run passed 1,082 main QML tests, plus 6 Outlook HTTP and 64 sidebar tests. The focused backend suite passed 24/24. QML lint and git diff --check passed.
  • A real isolated Rust subprocess handled 225 RPCs plus 24 mixed large MIME/body-cache/JSON transfers through the production Backend.qml functions and Upload.js; readback matched the uploaded content and every queue/reservation drained. This is now available through make test-backend-process before its existing Quickshell fixtures. The optional subprocess fixture is Unix-only and refuses Windows before creating storage or starting a backend, because its native known folders cannot be isolated through HOME/XDG overrides.
  • Pristine-main regressions failed on the pending-request cap, excess upload reservations and shutdown drain. Tests for both review findings were also observed failing before their fixes.
  • A fresh independent reviewer found mutable queued parameters and exception-sensitive failure fanout. Both were fixed and rechecked; no remaining blocking findings in the reviewed scope.

make validate is not fully green locally: its legacy libcurl tests/test_imap_ordering.sh fixture fails identically on pristine af8a7ae (the host curl returns the FETCH prefix without its literal body). Rust, JS and portable shell stages passed; the remaining QML/lint stages were run separately. Standalone composition requires missing CMake, and plugin/real-Quickshell validation requires missing Omarchy/Quickshell tools. The new native subprocess test does not substitute for a real Quickshell Process host or a live nine-account mailbox reproduction. This PR remains a draft with those local verification gaps disclosed.

Security

PASS for the affected framing, capacity, cancellation and payload-free diagnostic boundaries, based on independent review and the regression tests above. The affected boundary is bounded local RPC/upload scheduling over the existing private stdio connection. No new network, credential, filesystem or executable destination is introduced.

Release Notes

  • Large mailbox refreshes wait for available backend capacity instead of intermittently failing with pending-request or upload-capacity errors.
  • Cancelled internal uploads release their staged data without running a queued mail operation.

@huacnlee
huacnlee marked this pull request as ready for review September 30, 2026 16:52
@huacnlee
huacnlee merged commit 59ae988 into main Sep 30, 2026
14 checks passed
@huacnlee
huacnlee deleted the fix/backend-request-backpressure branch September 30, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant