re-enqueue amazon bedrock 503 failed requests

This commit is contained in:
reanon
2025-06-13 04:33:18 -08:00
+9 -7
View File
@@ -401,13 +401,15 @@ const handleUpstreamErrors: ProxyResHandlerWithBody = async (
} else if (statusCode === 503) {
switch (service) {
case "aws":
if (
errorType === "ServiceUnavailableException" &&
errorPayload.error?.message?.match(/too many connections/i)
) {
errorPayload.proxy_note = `The requested AWS Bedrock model is overloaded. Try again in a few minutes, or try another model.`;
}
break;
// Re-enqueue on any 503 from AWS Bedrock
req.log.warn(
{ key: req.key?.hash, errorType, errorPayload },
`AWS Bedrock service unavailable (503). Re-enqueueing request.`
);
await reenqueueRequest(req);
throw new RetryableError(
"AWS Bedrock service unavailable (503), re-enqueued request."
);
default:
errorPayload.proxy_note = `Upstream service unavailable. Try again later.`;
break;