Backport poller c6b601d#1255
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 96ac534. Configure here.
| _ => {} | ||
| } | ||
| }); | ||
| *guard = Some(handle); |
There was a problem hiding this comment.
Race between concurrent initiate_shutdown and shutdown loses RPC handle
Low Severity
When initiate_shutdown() is called concurrently from one thread (Thread A) while shutdown() is called from another (Thread B), Thread B's internal initiate_shutdown() sees already_initiated_shutdown = true and returns early without spawning. Thread B then proceeds to self.shutdown_rpc_handle.lock().take() which may return None if Thread A hasn't yet reached the mutex to store the handle. This causes shutdown() to skip awaiting the RPC, potentially proceeding to wait for polls to drain before the server has been told to release them—the exact deadlock scenario this PR aims to fix.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 96ac534. Configure here.


What was changed
Back port #1224 (commit 64cb6ed) onto commit c6b601d to fix poller shutdown for sdk-dotnet 1.12.0
Why?
Back port poller shutdown fix to affected SDKs
Checklist
Note
Medium Risk
Changes worker shutdown sequencing and poll-stream termination behavior, which is concurrency-sensitive and could affect how workers stop polling in production. Added tests reduce risk but regressions could still surface under real server/poll timing.
Overview
Fixes a graceful poll shutdown deadlock by moving the
ShutdownWorkerRPC intoWorker::initiate_shutdown(spawned in the background and awaited byWorker::shutdown) so the server is signaled to flush in-flight long polls.Updates poll-stream behavior so empty poll responses after shutdown are treated as a termination signal (instead of poll timeouts that retry forever), and threads namespace capability plumbing via a new exported
NamespaceCapabilities.Expands unit/integration coverage around shutdown (including a tight timer+activity loop scenario), adjusts heartbeat/shutdown assertions, enables the dev-server dynamic config for cancel-on-shutdown, and bumps the test CLI override to
v1.6.3-serverless.Reviewed by Cursor Bugbot for commit 96ac534. Bugbot is set up for automated code reviews on this repo. Configure here.