Repository navigation
Close rejected optional OpenCode billing requests - #26236
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe optional billing request now aborts when it receives a non-OK response, before returning a Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Rejected optional billing requests are now cancelled while retaining the disabled result and existing successful-response behavior. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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. Comment |
ELI5
A failed optional OpenCode billing check now closes its network request while still showing the valid quota result.
What Changed
Abort the optional billing request's existing controller when its HTTP response is rejected. It returns the same disabled balance result. Successful billing-body parsing keeps its five-second deadline; quota and workspace requests retain their independent deadlines.
Why
After rejected billing headers arrive, this path returns without reading the body and clears its only deadline. A stalled rejected body therefore leaves a physical Chromium request open even though the quota check and cookie cleanup have finished. The request already owns a controller, so a one-line abort closes that lifetime without closing the shared Session or changing cookies/proxy configuration.
The complete public fetcher and real Session cookie/proxy helper were exercised in windowless Electron 43.7.5 against a controlled HTTPS service. Three successive checks with valid quota and 1 KiB stalled billing failures retained three physical response owners before, including after forced GC and 5.5 seconds beyond the billing deadline; the fix retained zero and closed each in under 1 ms. All cookie jars were empty after each call. This demonstrates resource lifetime, not live OpenCode outage frequency, throughput, total memory or the reported Codex typing pause.
Linked Issue
Maintainer performance audit; no pre-existing linked issue.
Visual Proof
N/A — valid quota, balance errors and interactions are unchanged.
Testing
The existing valid-quota/optional-billing regression now checks request ownership, unread rejected bodies and cookie cleanup. The rejection assertion fails before the fix; successful unsupported billing consumes its body without aborting. All 61 rate-limit test files / 828 tests pass, with one existing skip. Node typecheck, two-file changed-code quality, formatting and fresh Electron build pass. Combined with the other 31 audit changes, all 831 rate-limit tests, full typecheck and the 102-file changed-code quality gate pass.
Eleven paired native controls preserve full normalized results, request counts, cookie/proxy helper calls and empty cookies: normal 7.5 USD balance, finite rejection, malformed/truncated billing, actual five-second timeout, failed/malformed quota, balance-only status and small stalled billing failures. The native proof used the default DIRECT proxy branch; configured proxies were not physically exercised, and proxy code is unchanged. Only service URLs and isolated probe partitions/certificate trust were controlled; no real account/API. An initial HTTP redirect rejected before requests was discarded. Probe apps, HTTPS server and all connections were closed afterward.
Review
Independently reviewed: this controller belongs only to the optional billing attempt, and later workspaces create new controllers. Existing Session cookie cleanup remains in finally; no global connection teardown, cache, remote wire or platform-specific behavior change. Local credential execution and folder/SSH workspace behavior are unchanged.
Agent skill upstream boundary
Checklist
Hosted followthrough: the first run failed in an unchanged Bash trap test after its five-second native command deadline and in nine unchanged Windows boundary tests. The failed Windows tests’ literal import closures exclude this PR’s OpenCode files. The complete Bash suite passes locally (37 cases). The single failed-jobs-only rerun passed with the source unchanged, including Windows packaging and the Node 24 shard; the final verification job passed. This does not establish the cause of the first failures. No timeout or readiness changes were made.