Repository navigation
fix channel init/shutdown race - #11853
Merged
Brett Samblanet (brettsam) merged 5 commits intoJul 10, 2026
Merged
Conversation
Brett Samblanet (brettsam)
force-pushed
the
brettsam/fix-channel-shutdown-race
branch
from
June 30, 2026 18:35
c264c36 to
63b1044
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a shutdown/initialization race in WebHostRpcWorkerChannelManager where host teardown could hang indefinitely if a worker channel was added but never finished initializing (its TaskCompletionSource was never completed).
Changes:
- Cancels in-flight channel initialization waiters during
ShutdownChannelsAsyncand disposes channels that complete initialization after shutdown has already removed their runtime entry. - Ensures channels are disposed when worker startup faults/cancels to prevent worker process leaks/hangs during teardown.
- Adds a regression unit test for the uninitialized-channel shutdown case and updates E2E fixture cleanup to explicitly stop/dispose the WebHost.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/WebJobs.Script.Grpc/Rpc/WebHostRpcWorkerChannelManager.cs | Adds cancellation/cleanup logic to prevent shutdown deadlocks and leaks when initialization races with teardown. |
| test/WebJobs.Script.Tests/Workers/Rpc/WebHostRpcWorkerChannelManagerTests.cs | Adds a regression test for shutdown while a channel is still uninitialized. |
| test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/EndToEndTestFixture.cs | Stops/disposes WebHost during E2E fixture cleanup to exercise the shutdown path. |
| test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/SamplesEndToEndTests_Node_MultipleProcessesNoBundle.cs | Adds fixture override to stop/dispose WebHost in cleanup (now redundant with base fixture). |
| release_notes.md | Adds a release note entry for the shutdown race fix. |
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Jacob Viau (jviau)
approved these changes
Jun 30, 2026
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Jacob Viau (jviau)
approved these changes
Jul 8, 2026
Member
Author
|
Copilot resolve the merge conflicts in this pull request |
Contributor
Merged |
sarah (satvu)
approved these changes
Jul 9, 2026
Brett Samblanet (brettsam)
deleted the
brettsam/fix-channel-shutdown-race
branch
July 10, 2026 16:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a WebHost RPC worker channel shutdown race where
ShutdownChannelsAsynccould wait forever on a worker channel that was added to the channel dictionary but had not finished initializing yet.The race was exposed by explicitly stopping and disposing WebHost instances in E2E fixture cleanup. If shutdown removed the runtime entry while initialization was still in flight, the initialization continuation could no longer complete the pending channel task, leaving shutdown blocked.
Changes
ShutdownChannelsAsyncso shutdown does not wait indefinitely.IMPORTANT: Currently, changes must be backported to the
in-procbranch to be included in Core Tools and non-Flex deployments.in-procbranch is not requiredrelease_notes.md