fix: Dynamic code cancellation no longer leaves Unity busy - #1369
Conversation
Dynamic snippets can return awaitables that never complete when user code ignores cancellation. Bind Task, ValueTask, and custom awaitable waits to the request token so CommandRunner releases its execution slot after client disconnects, and cover the blocked async-result path with an EditMode regression test.
Ensure canceled dynamic-code awaits observe late task faults, keep helper awaits context-free, and let already-completed returned tasks surface their result or exception instead of being overwritten by late cancellation.
|
Caution Review failedAn error occurred during the review process. Please try again later. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
📝 WalkthroughWalkthrough
ChangesCancellation-aware async execution
Sequence Diagram(s)sequenceDiagram
participant CommandRunner
participant AwaitIfNeeded
participant AwaitTaskWithCancellationAsync
participant ObserveAbandonedTaskFaultAsync
CommandRunner->>AwaitIfNeeded: AwaitIfNeeded(invoked, cancellationToken)
AwaitIfNeeded->>AwaitTaskWithCancellationAsync: forward task + cancellationToken
rect rgba(255, 100, 100, 0.5)
Note over AwaitTaskWithCancellationAsync: cancellation fires first
AwaitTaskWithCancellationAsync->>ObserveAbandonedTaskFaultAsync: attach fault-observer continuation
AwaitTaskWithCancellationAsync-->>AwaitIfNeeded: throw OperationCanceledException
AwaitIfNeeded-->>CommandRunner: propagate cancellation
end
rect rgba(100, 200, 100, 0.5)
Note over AwaitTaskWithCancellationAsync: task completes first
AwaitTaskWithCancellationAsync-->>AwaitIfNeeded: return Task<object> result
AwaitIfNeeded-->>CommandRunner: return result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Summary
User Impact
Changes
Verification
cli/dist/darwin-arm64/uloop compile --project-path "$(git rev-parse --show-toplevel)"cli/dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type regex --filter-value "io\\.github\\.hatayama\\.UnityCliLoop\\.Tests\\.Editor\\.DynamicCodeToolTests\\.CommandRunnerCancellationTests\\..*"cli/dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type regex --filter-value "io\\.github\\.hatayama\\.UnityCliLoop\\.Tests\\.Editor\\.DynamicCodeToolTests\\..*"~/.codex/skills/codex-review/scripts/codex-review --parallel-tests ... v3-betareturned clean with no accepted/actionable findings.