From eacd78444a03a59d9694225b8e0bafea3a8534a2 Mon Sep 17 00:00:00 2001 From: Alec Ananian <1013230+alecananian@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:31:37 -0700 Subject: [PATCH] api: ignore failures from thirdweb getUser feature --- apps/api/src/routes/auth.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/api/src/routes/auth.ts b/apps/api/src/routes/auth.ts index 09cb7397..f1262fb8 100644 --- a/apps/api/src/routes/auth.ts +++ b/apps/api/src/routes/auth.ts @@ -7,7 +7,7 @@ import type { FastifyPluginAsync } from "fastify"; import "../middleware/chain"; import "../middleware/swagger"; -import { getUser } from "thirdweb"; +import { type GetUserResult, getUser } from "thirdweb"; import type { LoginBody, LoginReply, @@ -119,14 +119,20 @@ export const authRoutes = if (adminAddress) { // Look up any associated user details in the embedded wallet - const thirdwebUser = await getUser({ - client, - ecosystem: { - id: env.THIRDWEB_ECOSYSTEM_ID, - partnerId: env.THIRDWEB_ECOSYSTEM_PARTNER_ID, - }, - walletAddress: adminAddress, - }); + let thirdwebUser: GetUserResult | null | undefined; + try { + thirdwebUser = await getUser({ + client, + ecosystem: { + id: env.THIRDWEB_ECOSYSTEM_ID, + partnerId: env.THIRDWEB_ECOSYSTEM_PARTNER_ID, + }, + walletAddress: adminAddress, + }); + } catch { + // Ignore failures from the Thirdweb SDK, this info is "nice-to-have" + } + if (thirdwebUser) { const email = parseThirdwebUserEmail(thirdwebUser); if (email) {