observability: defer and flush Sentry sends so they survive the serverless freeze - #10972
Conversation
… the lambda reportError queued captureException on a floating promise with no flush. On Vercel the function freezes right after the response, so the envelope never left the process: the shared project has zero events since the 2026-08-06 manual sanity checks, across coderouter, cloud VM, billing, and vm-alerts reporting. The send now runs inside next/server after() (so the 2s flush adds no user-visible latency) with a fire-and-forget fallback outside request scope, and explicitly awaits Sentry.flush.
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe Sentry reporter now defers request-time reporting with Next.js ChangesObservability reporting
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: 🔵 Low · up to This change improves Sentry delivery after serverless requests without affecting caller control flow or access controls. A bounded residual risk remains for error reports emitted outside request scope, which may still be lost if the process stops; the PR is mergeable with explicit owner awareness or follow-up. Sequence Diagram(s)sequenceDiagram
participant Request as Request context
participant After as Next.js after
participant Reporter as Sentry reporter
participant Sentry as Sentry SDK
Request->>Reporter: Report scrubbed context and fingerprint
Reporter->>After: Schedule reporting after response
After->>Reporter: Run asynchronous sender
Reporter->>Sentry: Load SDK and capture event
Reporter->>Sentry: Flush events for up to two seconds
🚥 Pre-merge checks | ✅ 23 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (23 passed)
Full details: Cmux Swift Actor IsolationExplanation PASS: The pull-request diff changes only Full details: Cmux Swift Blocking RuntimeExplanation PASS: The pull request changes only Full details: Cmux Browser Automation Off-MainExplanation PASS: The pull request changes only Full details: Cmux Expensive Synchronous LoadExplanation PASS: The pull request changes only Full details: Cmux Cache Substitution CorrectnessExplanation The check is not applicable. The only changed file is Full details: Cmux No Hacky SleepsExplanation The diff introduces no sleep, setTimeout, setInterval, polling loop, or fixed backoff. Full details: Cmux Algorithmic ComplexityExplanation PASS: The pull request changes only Full details: Cmux Swift ConcurrencyExplanation PASS: The pull-request diff against origin/main changes only web/services/observability/report.ts (+31/-15). It contains no Swift files and introduces no Swift concurrency patterns. The Swift-specific custom check is not applicable. Full details: Cmux Swift `@Concurrent`Explanation PASS: The pull request changes only Full details: Cmux Swift Package BoundariesExplanation PASS. The pull request changes only Full details: Cmux Swiftpm LockfilesExplanation PASS: The pull request changes only Full details: Cmux Swift LoggingExplanation PASS: The pull request changes only Full details: Cmux User-Facing Error PrivacyExplanation PASS: The pull request changes only Full details: Cmux Full InternationalizationExplanation PASS. The commit changes only Full details: Cmux Swiftui State LayoutExplanation PASS: The pull request changes only Full details: Cmux Architecture RethinkExplanation PASS: The pull request changes only Full details: Cmux Swift Auxiliary Window Close ShortcutsExplanation PASS: The pull request changes only Full details: Cmux Source ArtifactsExplanation The diff changes only Full details: Cmux No Test Or Debug Seam In Production SourceExplanation PASS — the custom check applies only to changed Swift files under production Full details: Cmux No Ambient Global StateExplanation PASS: The ambient-global-state policy applies to production Swift code. The pull-request diff contains exactly one changed file,
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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 |
87f3197 Integrate Escape passthrough fix from PR manaflow-ai#9810 (manaflow-ai#10959) aa8ca45 refactor(tui): share draw and paint render path (manaflow-ai#10970) 2f95b87 observability: flush Sentry after the response, or events never leave the lambda (manaflow-ai#10972)
* docs(tui): refresh intent and debt boards through 10962 * docs(tui): correct board snapshot metadata * docs(tui): advance boards through 10970 * docs(tui): align live board snapshot and merge ledger * docs(tui): record escape passthrough merge * docs(tui): record merged Sentry flush change * docs(tui): record alternate-screen wheel audit
31a7448 cmux-tui: re-land bounded relay lifecycle hardening d5ad6eb fix(tui): handle bounded response send errors 95abf7a docs(tui): refresh intent and debt boards through manaflow-ai#10972 (manaflow-ai#10971)
Live drills against production (deliberate vm_image_config_error after #10955 and #10968 deployed) produced the PostHog event but never a Sentry event. The project's event stream shows zero events since the manual sanity checks on 2026-08-06, across every reportError caller (coderouter, cloud VM, billing reconcile, vm-alerts webhook failures): the send was a floating promise with no flush, and the Vercel function freezes right after the response, so the SDK's queued envelope never left the process.
reportError now wraps the send in next/server
after()(deferred past the response, so the flush costs no user-visible latency; fire-and-forget fallback where no request scope exists) and awaitsSentry.flush(2000).Tests:
bun test tests/vm-observability.test.ts tests/coderouter-sentry.test.ts,bun run typecheckclean. Will verify live with another drill once deployed.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes Sentry error reporting in serverless functions so events reach Sentry instead of being dropped when the function freezes after the response.
reportErrornow defers the send withafter()and awaitsSentry.flush(2000); previously the send was a floating promise with no flush, so the Vercel function froze before the queued envelope left the process.Bug Fixes
after()fromnext/server, so the 2s flush adds no user-visible latency within a request; outside a request scope it falls back to fire-and-forget.Written for commit d41cac1. Summary will update on new commits.
Summary by CodeRabbit