Repository navigation
fix(wsl-host): a cold wake that loses orcad recovers by itself instead of leaving a dead pane #33147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(wsl-host): a cold wake that loses orcad recovers by itself instead of leaving a dead pane #33147
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { RemoteRuntimeClientError } from '../../shared/remote-runtime-client-error' | ||
| import { isRecoverableRemoteRuntimeConnectionError } from '../../shared/remote-runtime/remote-runtime-client-error-classification' | ||
| import { OrcadHostUnsupportedError } from '../orcad/orcad-host-unavailable' | ||
| import { | ||
| OrcadManagedIdentityError, | ||
| OrcadManagedPairingRejectedError | ||
| } from '../managed-server/lifecycle/orcad-managed-tunnel-identity' | ||
| import { OrcadManagedPairingRepairFailedError } from '../managed-server/lifecycle/orcad-managed-pairing-repair-failure' | ||
| import { retryableConnectFailure, settlingConnectFailure } from './wsl-host-connect-failure' | ||
| import { | ||
| WslDistroNotRunningError, | ||
| WslOrcadLaunchDeferredError | ||
| } from './wsl-orcad-connection-errors' | ||
|
|
||
| describe('retryableConnectFailure', () => { | ||
| it('turns a connect failure on a running host into a retryable one the renderer recognises', () => { | ||
| const failure = retryableConnectFailure('Ubuntu', new Error('orcad exited')) | ||
| expect(failure).toBeInstanceOf(RemoteRuntimeClientError) | ||
| expect(failure).toMatchObject({ code: 'remote_runtime_unavailable' }) | ||
| expect(isRecoverableRemoteRuntimeConnectionError({ message: String(failure) })).toBe(true) | ||
| }) | ||
|
|
||
| // Why final: each waits on the user; retrying would run a full deploy per pane until the deadline. | ||
| it.each([ | ||
| [ | ||
| 'a deferred update', | ||
| () => | ||
| new WslOrcadLaunchDeferredError({ | ||
| outcome: 'deferred', | ||
| distro: 'Ubuntu', | ||
| candidateVersion: '2.0.0', | ||
| code: 'live-terminals', | ||
| reason: 'Terminals are still running.', | ||
| forceable: true | ||
| }) | ||
| ], | ||
| ['an unsupported distro', () => new OrcadHostUnsupportedError('WSL 1')], | ||
| ['a stopped distro (no-boot refusal)', () => new WslDistroNotRunningError('Ubuntu')], | ||
| ['a foreign server', () => new OrcadManagedIdentityError(6790, 'another key')], | ||
| ['an unpaired server', () => new OrcadManagedPairingRejectedError('devices were reset')], | ||
| ['a failed re-pair', () => new OrcadManagedPairingRepairFailedError('refused again')] | ||
| ])('keeps %s final', (_label, make) => { | ||
| const refusal = make() | ||
| expect(retryableConnectFailure('Ubuntu', refusal)).toBe(refusal) | ||
| }) | ||
|
|
||
| it('reports a host still settling after an exit as retryable', () => { | ||
| const failure = settlingConnectFailure('Ubuntu') | ||
| expect(failure).toMatchObject({ code: 'remote_runtime_unavailable' }) | ||
| expect(isRecoverableRemoteRuntimeConnectionError({ message: String(failure) })).toBe(true) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { errorMessage } from '../../shared/error-message' | ||
| import { RemoteRuntimeClientError } from '../../shared/remote-runtime-client-error' | ||
| import { OrcadHostUnsupportedError } from '../orcad/orcad-host-unavailable' | ||
| import { | ||
| WslDistroNotRunningError, | ||
| WslOrcadLaunchDeferredError | ||
| } from './wsl-orcad-connection-errors' | ||
| import { | ||
| OrcadManagedIdentityError, | ||
| OrcadManagedPairingRejectedError | ||
| } from '../managed-server/lifecycle/orcad-managed-tunnel-identity' | ||
| import { OrcadManagedPairingRepairFailedError } from '../managed-server/lifecycle/orcad-managed-pairing-repair-failure' | ||
|
|
||
| /** | ||
| * Liveness keeps reconnecting a running host whose connect failed, so a call that met the failure | ||
| * reads as "not reachable yet" and retries instead of dead-ending its pane. Final: a deferred update, | ||
| * unsupported distro or identity/pairing refusal (they wait on the user) and a no-boot refusal (E9). | ||
| */ | ||
| export function retryableConnectFailure(distro: string, error: unknown): unknown { | ||
| if ( | ||
| error instanceof WslOrcadLaunchDeferredError || | ||
| error instanceof OrcadHostUnsupportedError || | ||
| error instanceof WslDistroNotRunningError || | ||
| // A foreign or unpaired server, or a failed re-pair, needs the user (as on the SSH tunnel path); | ||
| // retrying would run a full deploy per pane until the deadline. | ||
| error instanceof OrcadManagedIdentityError || | ||
| error instanceof OrcadManagedPairingRejectedError || | ||
| error instanceof OrcadManagedPairingRepairFailedError | ||
| ) { | ||
| return error | ||
| } | ||
| return notReachableYet(distro, errorMessage(error)) | ||
| } | ||
|
|
||
| /** Liveness is still deciding whether the distro stopped: a pane attaching now retries, never boots. */ | ||
| export function settlingConnectFailure(distro: string): RemoteRuntimeClientError { | ||
| return notReachableYet(distro, 'it is still settling after its server exited') | ||
| } | ||
|
|
||
| function notReachableYet(distro: string, reason: string): RemoteRuntimeClientError { | ||
| return new RemoteRuntimeClientError( | ||
| 'remote_runtime_unavailable', | ||
| // Why this wording: subscriptions cross IPC as a message, and renderers match this phrase. | ||
| `Could not connect to the remote Orca runtime in ${distro} yet: ${reason}` | ||
| ) | ||
| } | ||
|
|
||
| /** A `.catch` handler that rethrows a connect failure in its retryable-or-final form. */ | ||
| export function rethrowRetryable(distro: string): (error: unknown) => never { | ||
| return (error) => { | ||
| throw retryableConnectFailure(distro, error) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| */ | ||
| import { errorMessage } from '../../shared/error-message' | ||
| import { focusReachability } from './wsl-host-focus-reachability' | ||
| import { rethrowRetryable, settlingConnectFailure } from './wsl-host-connect-failure' | ||
| import { removeWslHostEnvironment } from '../../shared/runtime-environment-wsl-host-store' | ||
| import { | ||
| readWslHostDeployments, | ||
|
|
@@ -270,14 +271,13 @@ export class WslHostService { | |
| } | ||
| // Unconfirmed (running list unreadable, or possibly stale right after an exit) or not | ||
| // visible: refuse rather than risk a boot; liveness publishes the verdict. | ||
| if ( | ||
| reachability !== 'unreachable' || | ||
| !this.visible.has(environmentId) || | ||
| connector.isSettling(record.distro) | ||
| ) { | ||
| if (reachability !== 'unreachable' || !this.visible.has(environmentId)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔎 Supported by static analysis
Handle an unavailable running list while settling. When Suggested fix
|
||
| throw new Error(wslHostNotConnectedMessage(record.distro)) | ||
| } | ||
| await connector.connect(record.distro, { noBoot: true }) | ||
| if (connector.isSettling(record.distro)) { | ||
| throw settlingConnectFailure(record.distro) | ||
| } | ||
| await connector.connect(record.distro, { noBoot: true }).catch(rethrowRetryable(record.distro)) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,7 +177,8 @@ export class WslOrcadConnectionManager { | |
| // Taken before any await, so a close during the running-list read still supersedes this. | ||
| const generation = this.generation(key) | ||
| const stillCurrent = (): boolean => this.generation(key) === generation | ||
| await assertWslDistroMayStart(distro, options.requireRunning, stillCurrent) | ||
| const requireRunning = options.requireRunning | ||
| await assertWslDistroMayStart(distro, requireRunning, stillCurrent) | ||
| const environmentId = options.environmentId ?? defaultWslOrcadEnvironmentId(distro) | ||
| const label = options.label ?? distro | ||
| const target = { kind: 'wsl', id: environmentId, distro, label } as const | ||
|
|
@@ -190,7 +191,8 @@ export class WslOrcadConnectionManager { | |
| pairedOffer: this.enrolledOffer(key, environmentId), | ||
| signal: options.signal, | ||
| holder: this.dependencies.holder, | ||
| createTransport: () => transport | ||
| createTransport: () => transport, | ||
| ...(requireRunning ? { requireRunning: () => requireRunning(distro) } : {}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check currentness after the second running-state read. If |
||
| }) | ||
| if (launch.outcome === 'deferred') { | ||
| throw new WslOrcadLaunchDeferredError(launch) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep rejected readiness failures final.
If a visible-work reconnect receives
OrcadActiveReadinessErrorwith verdictrejected, this fallback converts it toremote_runtime_unavailable. The pane then retries a failure that deployment deliberately rejected, such as the wrong server build. Preserve that verdict instead of scheduling repeated reconnects.src/main/wsl/wsl-orcad-deploy.test.tsalready verifies that the rejected verdict does not trigger a second wake.