[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: handle errors from oauth client

+24 -13
+24 -13
server/utils/atproto/oauth.ts
··· 43 43 ) => Promise<D> 44 44 45 45 async function getOAuthSession(event: H3Event): Promise<OAuthSession | undefined> { 46 - const clientMetadata = getOauthClientMetadata() 47 - const serverSession = await useServerSession(event) 48 - const { stateStore, sessionStore } = useOAuthStorage(serverSession) 46 + try { 47 + const clientMetadata = getOauthClientMetadata() 48 + const serverSession = await useServerSession(event) 49 + const { stateStore, sessionStore } = useOAuthStorage(serverSession) 49 50 50 - const client = new NodeOAuthClient({ 51 - stateStore, 52 - sessionStore, 53 - clientMetadata, 54 - requestLock: getOAuthLock(), 55 - }) 51 + const client = new NodeOAuthClient({ 52 + stateStore, 53 + sessionStore, 54 + clientMetadata, 55 + requestLock: getOAuthLock(), 56 + }) 56 57 57 - const currentSession = await sessionStore.get() 58 - if (!currentSession) return undefined 58 + const currentSession = await sessionStore.get() 59 + if (!currentSession) return undefined 59 60 60 - // restore using the subject 61 - return await client.restore(currentSession.tokenSet.sub) 61 + // restore using the subject 62 + return await client.restore(currentSession.tokenSet.sub) 63 + } catch (error) { 64 + // Log error safely without using util.inspect on potentially problematic objects 65 + // The @atproto library creates error objects with getters that crash Node's util.inspect 66 + // eslint-disable-next-line no-console 67 + console.error( 68 + '[oauth] Failed to get session:', 69 + error instanceof Error ? error.message : 'Unknown error', 70 + ) 71 + return undefined 72 + } 62 73 } 63 74 64 75 /**