fix(compaction): retry transient native failures
(cherry picked from commit 293c96dfa479de13995d581caec33b3c90b5b3ca)
This commit is contained in:
@@ -2537,16 +2537,14 @@ export class SessionMaintenance {
|
||||
}
|
||||
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const id = AIError.classify(error, candidate.api);
|
||||
const id = AIError.classify(
|
||||
error instanceof NativeCompactionError ? error.cause : error,
|
||||
candidate.api,
|
||||
);
|
||||
if (AIError.is(id, AIError.Flag.AuthFailed)) {
|
||||
lastError = this.#buildCompactionAuthError();
|
||||
break;
|
||||
}
|
||||
if (error instanceof NativeCompactionError) {
|
||||
nativeCompactionFailure ??= { error, provider: candidate.provider };
|
||||
lastError = nativeCompactionFailure.error;
|
||||
break;
|
||||
}
|
||||
if (AIError.is(id, AIError.Flag.Timeout)) {
|
||||
logger.warn(
|
||||
hasMoreCandidates
|
||||
@@ -2569,7 +2567,12 @@ export class SessionMaintenance {
|
||||
AIError.is(id, AIError.Flag.Transient) ||
|
||||
AIError.is(id, AIError.Flag.UsageLimit));
|
||||
if (!shouldRetry) {
|
||||
lastError = error;
|
||||
if (error instanceof NativeCompactionError) {
|
||||
nativeCompactionFailure ??= { error, provider: candidate.provider };
|
||||
lastError = nativeCompactionFailure.error;
|
||||
} else {
|
||||
lastError = error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2579,6 +2582,11 @@ export class SessionMaintenance {
|
||||
// If retry delay is too long (>30s), try next candidate instead of waiting
|
||||
const maxAcceptableDelayMs = 30_000;
|
||||
if (delayMs > maxAcceptableDelayMs && hasMoreCandidates) {
|
||||
if (error instanceof NativeCompactionError) {
|
||||
nativeCompactionFailure ??= { error, provider: candidate.provider };
|
||||
lastError = nativeCompactionFailure.error;
|
||||
break;
|
||||
}
|
||||
logger.warn("Auto-compaction retry delay too long, trying next model", {
|
||||
delayMs,
|
||||
retryAfterMs,
|
||||
|
||||
Reference in New Issue
Block a user