Repository navigation
Description
What
The background service's persistent-terminal handoff step is best-effort in upstream's first-party client: any failure of the step is caught, and the old service is still terminated. The SDK's step catches two exception types only. An exception of any other type ends StopAsync, or the EnsureAsync election, before the terminate.
Upstream at the pin (v2.3.0)
stopcatches any failure of the handoff or clear and only warns, then terminates:packages/client/src/promise/service.ts:105-111. The Effect twin does the same atpackages/client/src/effect/service.ts:133-137.ensure's replacement wraps the whole stop in.catch(() => undefined):packages/client/src/promise/service.ts:84. A failure of the replacement stop, terminate included, never endsensure.
The SDK today
Paths are at the head of the #842 change, e105aceb, which lifts the election's step into a shared type unchanged. On master before it, the same catch is in ServiceElection.PrepareOrClearAsync, and the stop's own sidecar clear catches only OpenCodeServerException.
- The shared step,
ServicePtyHandoffStep.RunAsync(src/OpenCode.Sdk/Hosting/BackgroundService/Internal/Handoff/ServicePtyHandoffStep.cs:28), catches onlyOpenCodeServerExceptionandArgumentException { ParamName: "endpoint" }. BothServiceStopperandServiceElection.ReplaceAsyncuse it. ServiceElection.ReplaceAsync(src/OpenCode.Sdk/Hosting/BackgroundService/Internal/Ensure/ServiceElection.cs:178) catches onlyOpenCodeServerExceptionaround the read, the step and the terminate.
The failure path
When the handoff seam throws anything else:
StopAsyncthrows, and the registered service keeps running, where upstream'sstopterminates it.EnsureAsync's version-mismatch replacement throws out of the election, and the old service keeps running, where upstream'sensuregoes on probing.
An example is an I/O failure that the seam does not map to OpenCodeServerException. It has not been checked whether any concrete exception type escapes the seam's mapping today. The gap is in the shape of the catch.
Decision needed
Parity widens a guarded catch. The step's catch carries a slopwatch SW003 suppression whose reason names upstream's best-effort catch, and a wider catch also meets the analyzers' general-catch rules. So it is the maintainer's call: widen to upstream's catch-all (with the caller's cancellation still propagating), or keep the narrow set and record it as a divergence.
Found in review of the handoff-mode change for StopAsync (#842), which shares this step and does not change its catch beyond the endpoint case.
Activity