From 489a8a5791f40f7d7678410fb3923d8eb743e4e3 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Mon, 8 Dec 2025 01:48:41 +0100 Subject: [PATCH] Fix pino logger error calls to properly serialize errors Pino expects error object first, message second: logger.error(err, 'msg') The previous pattern logger.error('msg', err) silently discarded errors. Fixed in: - apps/blog/app/[param]/[p2]/[permlink]/layout.tsx - packages/smart-signer/lib/verify-login.ts - packages/smart-signer/lib/auth/use-logout.ts - packages/smart-signer/lib/api-handlers/auth/consent.ts - packages/smart-signer/lib/api-handlers/auth/chat-token.ts Also added .pnpm-store to .gitignore. --- .gitignore | 1 + apps/blog/app/[param]/[p2]/[permlink]/layout.tsx | 2 +- packages/smart-signer/lib/api-handlers/auth/chat-token.ts | 2 +- packages/smart-signer/lib/api-handlers/auth/consent.ts | 2 +- packages/smart-signer/lib/auth/use-logout.ts | 4 ++-- packages/smart-signer/lib/verify-login.ts | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 84bbcdd07..d371e990e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules +.pnpm-store .turbo .idea .next diff --git a/apps/blog/app/[param]/[p2]/[permlink]/layout.tsx b/apps/blog/app/[param]/[p2]/[permlink]/layout.tsx index b411636a0..9538b3b91 100644 --- a/apps/blog/app/[param]/[p2]/[permlink]/layout.tsx +++ b/apps/blog/app/[param]/[p2]/[permlink]/layout.tsx @@ -49,7 +49,7 @@ export async function generateMetadata({ } }; } catch (error) { - logger.error('Error in generateMetadata:', error); + logger.error(error, 'Error in generateMetadata'); return { title: 'Hive', description: 'Hive: Communities Without Borders.', diff --git a/packages/smart-signer/lib/api-handlers/auth/chat-token.ts b/packages/smart-signer/lib/api-handlers/auth/chat-token.ts index c66277e1d..a43948000 100644 --- a/packages/smart-signer/lib/api-handlers/auth/chat-token.ts +++ b/packages/smart-signer/lib/api-handlers/auth/chat-token.ts @@ -27,7 +27,7 @@ export const getChatToken: NextApiHandler = async (req, res) => { ); user = session.user; } catch (error) { - logger.error('getChatToken error:', error); + logger.error(error, 'getChatToken error'); } if (!( diff --git a/packages/smart-signer/lib/api-handlers/auth/consent.ts b/packages/smart-signer/lib/api-handlers/auth/consent.ts index ce38ad1dc..32787b7b0 100644 --- a/packages/smart-signer/lib/api-handlers/auth/consent.ts +++ b/packages/smart-signer/lib/api-handlers/auth/consent.ts @@ -27,7 +27,7 @@ export const registerConsent: NextApiHandler = async (req, res) => { ); user = session.user; } catch (error) { - logger.error('registerConsent error:', error); + logger.error(error, 'registerConsent error'); } if (!(user?.isLoggedIn && user.username)) { diff --git a/packages/smart-signer/lib/auth/use-logout.ts b/packages/smart-signer/lib/auth/use-logout.ts index d42c50cc7..c15fd280b 100644 --- a/packages/smart-signer/lib/auth/use-logout.ts +++ b/packages/smart-signer/lib/auth/use-logout.ts @@ -31,7 +31,7 @@ export function useLogout(redirect?: string) { }) }); } catch (logError) { - logger.error('Failed to log logout event:', logError); + logger.error(logError, 'Failed to log logout event'); } } await signOut.mutateAsync({ user }); @@ -43,7 +43,7 @@ export function useLogout(redirect?: string) { description: 'Logout failed', variant: 'destructive' }); - logger.error('Error in logout', error); + logger.error(error, 'Error in logout'); } finally { if (redirect) { router.push(redirect); diff --git a/packages/smart-signer/lib/verify-login.ts b/packages/smart-signer/lib/verify-login.ts index 7f4e431b4..35e3970d4 100644 --- a/packages/smart-signer/lib/verify-login.ts +++ b/packages/smart-signer/lib/verify-login.ts @@ -29,7 +29,7 @@ export async function verifyLogin(data: PostLoginSchema): Promise { }; return user; } catch (error) { - logger.error('error in verifyLogin', error); + logger.error(error, 'Error in verifyLogin'); throw error; } } -- GitLab