fix(api): map upstream timeouts to 504 responses

This commit is contained in:
2026-04-21 13:32:12 +00:00
parent d6b4c0def1
commit fe4fdb32d7
4 changed files with 154 additions and 0 deletions
+12
View File
@@ -24,6 +24,13 @@ export type TModelPullProgress = (progress: {
percent?: number;
}) => void;
export class UpstreamTimeoutError extends Error {
constructor(message: string = 'Upstream request timed out') {
super(message);
this.name = 'UpstreamTimeoutError';
}
}
/**
* Abstract base class for AI model containers
*/
@@ -181,6 +188,11 @@ export abstract class BaseContainer {
});
return response;
} catch (error) {
if (error instanceof Error && error.name === 'AbortError') {
throw new UpstreamTimeoutError();
}
throw error;
} finally {
clearTimeout(timeoutId);
}