Skip to content

fix: stop Roslyn worker revive after server reset or reload shutdown#1763

Merged
hatayama merged 1 commit into
feature/dynamic-code-slot-recoveryfrom
fix/roslyn-worker-no-revive-after-shutdown
Jul 13, 2026
Merged

fix: stop Roslyn worker revive after server reset or reload shutdown#1763
hatayama merged 1 commit into
feature/dynamic-code-slot-recoveryfrom
fix/roslyn-worker-no-revive-after-shutdown

Conversation

@hatayama

@hatayama hatayama commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • After server reset / domain reload / Editor quit, an in-flight shared Roslyn compile retry no longer starts a replacement worker.
  • Ordinary crash/retry cleanup still may restart the worker within the same compile conversation.

User Impact

  • Before: Shutdown could interleave with retry → EnsureWorkerReady briefly resurrected a worker (stdin EOF self-exits; no lasting leak, but wrong lifecycle).
  • After: Full lifecycle Shutdown advances a generation latch; stale retries fail closed without starting a new process. The next compile after reset captures the new generation and works normally.

Design

  • Generation latch on SharedRoslynCompilerWorkerSession (not sticky bool + GetRuntimeFacade clear).
  • Shutdown() advances generation under the state lock, then kills the process.
  • ShutdownProcessLocked alone does not advance generation (legitimate retry).
  • TryCompileWithRetriesAsync captures generation via lock; EnsureWorkerReady / StartWorkerProcess compare+start atomically under the same lock.
  • Non-retryable failure reason: shared_worker_lifecycle_closed.

Out of scope (umbrella notes)

  • Mapping shared_worker_lifecycle_closed to PR 6-2 restarting NextActions if/when it becomes user-visible.

Verification

  • uloop compile → Success
  • 3 EditMode tests: Shutdown advances gen; process-only shutdown still allows restart; stale gen refuses start → Passed

Test plan

  • Confirm process-only kill still allows StartProcessLocked for the captured generation
  • Confirm full Shutdown advances generation and refuses stale starts
  • Optional Editor: reset during compile should not leave a resurrected worker for that conversation

Made with Cursor

Review in cubic

Advance a session lifecycle generation on full Shutdown so in-flight
compile retries cannot restart the worker after reset/reload/quit, while
process-only retry cleanup still allows a legitimate replacement start.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@hatayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

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, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fcee9335-38fa-4f95-a9e6-61cbbaa39891

📥 Commits

Reviewing files that changed from the base of the PR and between f16dd0c and 50bb7d1.

📒 Files selected for processing (3)
  • Assets/Tests/Editor/DynamicCodeToolTests/SharedRoslynCompilerWorkerHostTests.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/SharedRoslynCompilerWorkerHost.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/SharedRoslynCompilerWorkerSession.cs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/roslyn-worker-no-revive-after-shutdown

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hatayama

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hatayama
hatayama merged commit d59a625 into feature/dynamic-code-slot-recovery Jul 13, 2026
2 checks passed
@hatayama
hatayama deleted the fix/roslyn-worker-no-revive-after-shutdown branch July 13, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant