Skip to content

Commit

Permalink
fix: Ease timeout condition to also use 503 response
Browse files Browse the repository at this point in the history
  • Loading branch information
neet committed Dec 8, 2024
1 parent c2df98e commit df0b3cd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/app/[locale]/_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ export async function translate(

return result;
} catch (error) {
if (error instanceof DOMException && error.name === "TimeoutError") {
console.log(error);
if (
(error instanceof Error &&
error.cause instanceof Response &&
error.cause.status === 503) ||
(error instanceof DOMException && error.name === "TimeoutError")
) {
return {
type: "error",
message:
Expand Down

0 comments on commit df0b3cd

Please sign in to comment.