fix(hopper): report launcher failures before bridge timeout (#1105)

* fix(hopper): report launcher failures before bridge timeout

* fix(hopper): separate helper ownership from GUI lifetime
This commit is contained in:
Ysopwnable
2026-10-09 01:51:45 +08:00
committed by GitHub
parent 7914e36ab9
commit cd756b07d5
11 changed files with 270 additions and 28 deletions
+5 -1
View File
@@ -209,6 +209,8 @@ const RESTART_OWNED_PROVIDER =
const hopperProcessRemediation = (error: HopperProcessError): string => {
if (error.failureCode !== undefined && error.userMessage !== undefined)
return error.userMessage;
if (error.stage === "launch")
return "Review the captured launcher diagnostics and Hopper setup, then retry opening the target.";
if (providerRetryAction(error.providerState) === "restart_provider")
return RESTART_OWNED_PROVIDER;
return "Read binary_session.provider_operation_health for this request before retrying or restarting the owned provider.";
@@ -229,7 +231,9 @@ const hopperProcessMessage = (error: HopperProcessError): string => {
? "no exit code was observed"
: `exit code ${String(error.exitCode)}`;
const recovery =
error.failureCode === undefined ? ` ${RESTART_OWNED_PROVIDER}` : "";
error.failureCode === undefined && stage !== "launch"
? ` ${RESTART_OWNED_PROVIDER}`
: "";
return `Hopper exited during ${where} (${exit}).${startup}${recovery}${request}`;
}
if (error.providerState === "unreachable")
+7 -1
View File
@@ -352,7 +352,7 @@ const providerErrorDetails = (
provider_state: error.providerState,
retry_action: providerRetryAction(
error.providerState,
error.failureCode !== undefined,
error.failureCode !== undefined || error.stage === "launch",
),
...(error.failureCode === undefined
? {}
@@ -362,6 +362,9 @@ const providerErrorDetails = (
...(error.diagnostic === undefined
? {}
: { diagnostics: { ...error.diagnostic } }),
...(error.launcherFailure === undefined
? {}
: { launcher: error.launcherFailure }),
};
}
if (error instanceof HopperStartError)
@@ -372,6 +375,9 @@ const providerErrorDetails = (
...(error.ownerRunId === undefined
? {}
: { owner_run_id: error.ownerRunId }),
...(error.launcherFailure === undefined
? {}
: { launcher: error.launcherFailure }),
};
return undefined;
};
+14
View File
@@ -13,6 +13,16 @@ import {
/** Base class for failures produced specifically by the Hopper provider. */
export abstract class HopperError extends AnalysisError {}
/** Observed launcher outcome; a helper exit does not establish GUI lifetime. */
export type HopperLauncherOutcome = {
readonly exit_code: number | null;
readonly signal: string | null;
readonly stdout: { readonly text: string; readonly bytes: number };
readonly stderr: { readonly text: string; readonly bytes: number };
readonly output_closed: boolean;
readonly diagnostic_truncated: boolean;
};
/** Hopper did not respond within the configured operation deadline. */
export class HopperTimeoutError extends HopperError {
readonly _tag = "HopperTimeoutError";
@@ -93,6 +103,7 @@ export class HopperProcessError extends HopperError {
readonly requestId?: number,
providerState?: HopperProcessProviderState,
stage?: ProviderFailureStage,
readonly launcherFailure?: HopperLauncherOutcome,
) {
super(`Hopper bridge stopped unexpectedly with code ${String(exitCode)}`);
const failure = hopperStartupFailure(exitCode);
@@ -115,15 +126,18 @@ export class HopperStartError extends HopperError {
readonly _tag = "HopperStartError";
override readonly userMessage: string | undefined;
readonly ownerRunId: string | undefined;
readonly launcherFailure: HopperLauncherOutcome | undefined;
constructor(
options?: ErrorOptions & {
readonly userMessage?: string;
readonly ownerRunId?: string;
readonly launcherFailure?: HopperLauncherOutcome;
},
) {
super("Hopper application bridge could not be started", options);
this.userMessage = options?.userMessage;
this.ownerRunId = options?.ownerRunId;
this.launcherFailure = options?.launcherFailure;
}
}