Split server start/wait/stop lifecycle - #648
Merged
Merged
Conversation
SunSi12138
force-pushed
the
issue-646-server-lifecycle
branch
3 times, most recently
from
September 10, 2026 10:39
89fbb09 to
23bc348
Compare
SunSi12138
marked this pull request as ready for review
September 10, 2026 10:47
SunSi12138
commented
Sep 10, 2026
SunSi12138
left a comment
Owner
Author
There was a problem hiding this comment.
整体 Start/Wait/Stop 分域、Host bridge 和 shared-stop cancellation 方向合理,exact-head Quick / Release Gate / CodeQL 也已通过。当前有一个 failure-domain blocker:本 PR 把共享 TrackFrameworkTask 中的所有异常都升级为 Server terminal failure,但该 tracker 同时承载 per-connection lifecycle task,而连接 cleanup 明确允许抛异常;这会让单个坏连接/transport cleanup 把整个 Server 置为 Faulted。见 inline。
SunSi12138
force-pushed
the
issue-646-server-lifecycle
branch
from
September 10, 2026 13:09
5e1a6c6 to
351992a
Compare
Replace public RunAsync with explicit StartAsync, WaitForShutdownAsync, and StopAsync ownership. Move accept/runtime supervision into SharpLinkServer, keep per-connection cleanup failures local including heartbeat-timeout cleanup, simplify Generic Host lifetime bridging, migrate repository callers, and document terminal failure semantics. Fixes #646
SunSi12138
force-pushed
the
issue-646-server-lifecycle
branch
3 times, most recently
from
September 10, 2026 13:44
99b37d9 to
b3b372a
Compare
This was referenced Sep 10, 2026
This was referenced Sep 10, 2026
SunSi12138
added a commit
that referenced
this pull request
Sep 12, 2026
#677) * Bump the testing group with 1 update Bumps TUnit from 1.63.0 to 1.64.6 --- updated-dependencies: - dependency-name: TUnit dependency-version: 1.64.6 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: testing ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump github/codeql-action/init from 4.37.4 to 4.37.6 Bumps [github/codeql-action/init](https://github.com/github/codeql-action) from 4.37.4 to 4.37.6. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@f205ea1...5595cca) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.37.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * chore(ci): pair CodeQL actions at 4.37.6 * Bump Microsoft.Extensions.DependencyInjection and 6 others Bumps Microsoft.Extensions.DependencyInjection from 10.0.10 to 10.0.11 Bumps Microsoft.Extensions.DependencyInjection.Abstractions from 10.0.10 to 10.0.11 Bumps Microsoft.Extensions.Diagnostics.HealthChecks from 10.0.10 to 10.0.11 Bumps Microsoft.Extensions.Hosting from 10.0.10 to 10.0.11 Bumps Microsoft.Extensions.Logging to 10.0.11 Bumps Microsoft.Extensions.Logging.Abstractions from 10.0.10 to 10.0.11 Bumps Microsoft.Extensions.Logging.Console from 10.0.10 to 10.0.11 --- updated-dependencies: - dependency-name: Microsoft.Extensions.DependencyInjection dependency-version: 10.0.11 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoft-extensions - dependency-name: Microsoft.Extensions.DependencyInjection.Abstractions dependency-version: 10.0.11 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoft-extensions - dependency-name: Microsoft.Extensions.Diagnostics.HealthChecks dependency-version: 10.0.11 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoft-extensions - dependency-name: Microsoft.Extensions.Hosting dependency-version: 10.0.11 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoft-extensions - dependency-name: Microsoft.Extensions.Logging dependency-version: 10.0.11 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoft-extensions - dependency-name: Microsoft.Extensions.Logging dependency-version: 10.0.11 dependency-type: direct:production update-type: version-update:semver-major dependency-group: microsoft-extensions - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-version: 10.0.11 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoft-extensions - dependency-name: Microsoft.Extensions.Logging.Console dependency-version: 10.0.11 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: microsoft-extensions ... Signed-off-by: dependabot[bot] <support@github.com> * chore: bump version to 1.1.2 * Bump the testing group with 1 update Bumps TUnit from 1.64.6 to 1.65.68 --- updated-dependencies: - dependency-name: TUnit dependency-version: 1.65.68 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: testing ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump github/codeql-action/analyze from 4.37.6 to 4.37.9 Bumps [github/codeql-action/analyze](https://github.com/github/codeql-action) from 4.37.6 to 4.37.9. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@5595cca...cdf488f) --- updated-dependencies: - dependency-name: github/codeql-action/analyze dependency-version: 4.37.9 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump github/codeql-action/init from 4.37.6 to 4.37.9 Bumps [github/codeql-action/init](https://github.com/github/codeql-action) from 4.37.6 to 4.37.9. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@5595cca...cdf488f) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.37.9 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump Microsoft.CodeAnalysis.CSharp from 5.6.0 to 5.9.0 * Bump the roslyn group with 2 updates Bumps Microsoft.CodeAnalysis.Analyzers from 5.6.0 to 5.9.0 Bumps Microsoft.CodeAnalysis.CSharp from 5.0.0 to 5.9.0 --- updated-dependencies: - dependency-name: Microsoft.CodeAnalysis.Analyzers dependency-version: 5.9.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: roslyn - dependency-name: Microsoft.CodeAnalysis.CSharp dependency-version: 5.9.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: roslyn ... Signed-off-by: dependabot[bot] <support@github.com> * Bump the testing group with 1 update Bumps TUnit from 1.65.68 to 1.66.16 --- updated-dependencies: - dependency-name: TUnit dependency-version: 1.66.16 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: testing ... Signed-off-by: dependabot[bot] <support@github.com> * Decouple client lifecycle from remote readiness Introduce independent local lifecycle, readiness, and cluster state domains for single- and multi-cluster clients. Start hosted clients without blocking on remote availability, supervise initial connectivity recovery, preserve legacy explicit connection semantics, keep runtime Add/Replace candidates in the new child lifecycle, and prevent compatibility connection failures from tearing down an already-running coordinator. Fixes #644 * Split server start, wait, and stop lifecycle Replace public RunAsync with explicit StartAsync, WaitForShutdownAsync, and StopAsync ownership. Move accept/runtime supervision into SharpLinkServer, keep per-connection cleanup failures local including heartbeat-timeout cleanup, simplify Generic Host lifetime bridging, migrate repository callers, and document terminal failure semantics. Fixes #646 * Revert "Merge pull request #648 from SunSi12138/issue-646-server-lifecycle" This reverts commit 8183ac2, restoring the first-parent tree at 9ba50b9. * Revert "Merge pull request #647 from SunSi12138/issue-644-client-lifecycle-readiness" This reverts commit 9ba50b9, restoring the pre-accident main tree at 21ed74f. * perf(client): observe unary emission within the send pump lifetime * perf(runtime): batch ready timed requests at one emission boundary --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: sunsi <suns12138@163.com>
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.
Motivation
Fixes #646 by making Server lifecycle explicit and single-owner: startup, long-running serving, terminal waiting, and shutdown are no longer combined in public
RunAsync.Changes
RunAsyncwithStartAsync,WaitForShutdownAsync, andStopAsyncas the only canonical Server lifecycle primitives.SharpLinkServerLifecycleStateindependently fromHealthStatus.SharpLinkServer.WaitForShutdownAsynca pure terminal observer; caller cancellation only cancels that wait.StopAsyncas one shared Server-owned shutdown operation; caller cancellation does not cancel or force the shared drain._runTask/_runCts; Host Start/Stop bridge directly to Server Start/Stop, with only a terminal observer for unexpected Server termination. Hosted Stop callers also only cancel their own wait.Lifecycle semantics
StartAsyncpublishesRunningonly after the Server-owned accept operation has established its startup boundary; an immediate listener/accept failure is surfaced to the startup caller.StartAsync; they are not deferred to a background task.SharpLinkServer; unrecoverable runtime failures converge on one terminal cleanup path andFaultedstate.WaitForShutdownAsyncnever initiates shutdown and completes/faults only when terminal cleanup is published.StopAsyncownsDraining -> Stopped/Faulted; all callers join the same operation and terminal failures are consistent withWaitForShutdownAsync.StopAsyncfromCreatedproduces a real terminalStoppedstate; startup cancellation does not become a long-lived Server lifetime token afterRunningis published.Validation
Final head:
b3b372a45fb1baae1e1fa4ffe7e1145d644f0702(single commit on currentmain).TrackFrameworkTaskand terminalTrackServerRuntimeTask; per-connection/deferred cleanup keeps the local policy.DisconnectHeartbeatTimedOutConnectionAsyncisolates/logs heartbeat-timeout connection cleanup faults without downgrading the heartbeat supervisor itself.ConnectionCleanupFailureShouldNotTerminateServerRuntimeandHeartbeatCleanupFailureShouldNotTerminateServerRuntime; both verify local cleanup failure does not terminate the Server, with the latter also proving accept continues after heartbeat cleanup failure.RunAsynccompatibility entry remains; Generic Host has no run-loop CTS/task and no caller-cancellationForceStoppath; lifecycle coordination is isolated inSharpLinkServer.PublicLifecycle.cs; no temporary issue-646 workflow/script files remain in the PR tree.