Skip to content

Commit 2d00846

Browse files
committed
chore: catch firebase internal errors when trying to auth
1 parent 8843c50 commit 2d00846

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

backend/src/middlewares/auth.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,17 @@ async function authenticateWithBearerToken(
191191
email: decodedToken.email ?? "",
192192
};
193193
} catch (error) {
194+
if (
195+
error instanceof Error &&
196+
error.message.includes("An internal error has occurred")
197+
) {
198+
throw new MonkeyError(
199+
503,
200+
"Firebase returned an internal error when trying to verify the token.",
201+
"authenticateWithBearerToken"
202+
);
203+
}
204+
194205
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
195206
const errorCode = error?.errorInfo?.code as string | undefined;
196207

0 commit comments

Comments
 (0)