mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(ocm): abort the feature probe with the caller signal and keep fusion request ids across reopened multi-run commands
This commit is contained in:
1 parent
c41149dc39
commit
390f95710c
4 files changed
+42
-11
No files matched your search
@@ -151,21 +151,30 @@ export class ManagerApi {
|
||||
...requestInit,
|
||||
headers: { ...baseHeaders, ...(requestInit.headers as Record<string, string> | undefined) },
|
||||
})
|
||||
if (!res.ok) throw await this.handleErrorResponse(res, operation, feature === true)
|
||||
if (!res.ok) throw await this.handleErrorResponse(res, operation, feature === true, requestInit.signal ?? undefined)
|
||||
return parse(await res.json())
|
||||
}
|
||||
|
||||
private async handleErrorResponse(res: Response, operation: string, feature: boolean): Promise<ManagerApiError> {
|
||||
private async handleErrorResponse(
|
||||
res: Response,
|
||||
operation: string,
|
||||
feature: boolean,
|
||||
signal?: AbortSignal,
|
||||
): Promise<ManagerApiError> {
|
||||
const error = await formatErrorResponse(res, operation)
|
||||
if (feature && error.status === 401) {
|
||||
return this.probeFeatureSupport(operation, error)
|
||||
return this.probeFeatureSupport(operation, error, signal)
|
||||
}
|
||||
return error
|
||||
}
|
||||
|
||||
private async probeFeatureSupport(operation: string, fallback: ManagerApiError): Promise<ManagerApiError> {
|
||||
private async probeFeatureSupport(
|
||||
operation: string,
|
||||
fallback: ManagerApiError,
|
||||
signal?: AbortSignal,
|
||||
): Promise<ManagerApiError> {
|
||||
try {
|
||||
const res = await fetch(`${this.baseUrl}/api/internal/opencode-workspaces`, { headers: this.headers() })
|
||||
const res = await fetch(`${this.baseUrl}/api/internal/opencode-workspaces`, { headers: this.headers(), signal })
|
||||
if (res.ok) {
|
||||
return new ManagerApiError(
|
||||
`${operation} failed: this OpenCode Manager is too old for ocm goals and multi-runs; upgrade the Manager.`,
|
||||
|
||||
Reference in new issue
Block a user