ADFA-4328: Fix ClosedReceiveChannelException on debounced-action cancel#1409
ADFA-4328: Fix ClosedReceiveChannelException on debounced-action cancel#1409fryanpan wants to merge 3 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 27 minutes and 36 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 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 |
Sentry APPDEVFORALL-14C. Cancel job before closing channel, use receiveCatching, add a CoroutineExceptionHandler to the LSP scope. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-close crash Adds a :common unit test that parks a debounce worker on channel.receive(), cancels the entry, and asserts no ClosedReceiveChannelException escapes to the scope CoroutineExceptionHandler. Red on the pre-fix baseline (cancel() closed the channel before cancelling the job), green with the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
623aec8 to
5a39efa
Compare
Jira Ticket: https://appdevforall.atlassian.net/browse/ADFA-4328
Sentry Issue: https://appdevforall-inc-9p.sentry.io/issues/APPDEVFORALL-14C
Reproduction Details
KeyedDebouncingAction.ActionEntry.cancel()closed the (CONFLATED) channel before cancelling the worker job. A worker parked onchannel.receive()is woken by the close with aClosedReceiveChannelException— which is not aCancellationException, so it escapes uncaught to the worker'sCoroutineScopeand crashes the app.Stack Trace
User Steps
User steps leading up to crash, based on Sentry breadcrumbs:
createSearchScopes) debounce workers are active.KotlinLanguageServer.onDocumentClose→CompilationEnvironment.onFileClosed→cancelPendingcancels the debounced action while a worker is parked onreceive()→ uncaughtClosedReceiveChannelException.Was able to reproduce in a unit test?
Yes.
KeyedDebouncingActionCancelTest(:common) starts a worker, parks it onreceive(), then cancels and asserts nothing escapes to a recordingCoroutineExceptionHandler. Baseline (close-then-cancel): FAILS withClosedReceiveChannelException. Branch: passes.What Was Fixed
In
cancel(), cancel the job first, then close the channel; wrap the worker loop intry { … } catch (ClosedReceiveChannelException) { break } catch (CancellationException) { throw e }.CompilationEnvironmentalso adds a defensiveCoroutineExceptionHandlerthat logs non-cancellation failures.Testing
:common:testV8DebugUnitTest→ green (red on baseline, green on fix, single worktree). Local CodeRabbit review: no findings.Fixes APPDEVFORALL-14C