Browse Source

chore(ssr): add debug logging for marriage cookie parsing and profile initialization

Add detailed server-side logging in `RootLayout` and `Providers` to
monitor the lifecycle of the `rawMarriageCookie` parsing process and
the subsequent hydration of the `QueryClient` cache with the
`initialProfile`. This facilitates easier debugging of SSR data
flow and profile synchronization issues.
mortezaei 2 weeks ago
parent
commit
86d6a3136d
  1. 20
      src/app/layout.tsx
  2. 10
      src/app/providers.tsx

20
src/app/layout.tsx

@ -61,14 +61,32 @@ export default async function RootLayout({
const parsed = JSON.parse(decoded);
initialMarriageJson = decoded;
initialProfile = getInitialMarriageProfile(parsed);
console.log("🖥️ [SSR Layout] Parsed rawMarriageCookie successfully:", {
status: initialProfile?.status,
gender: initialProfile?.gender,
has_match_summary: Boolean(initialProfile?.match_summary),
match_summary_id: initialProfile?.match_summary?.id,
public_info_count: initialProfile?.match_summary?.public_info?.length,
});
} catch {
try {
const parsed = JSON.parse(rawMarriageCookie);
initialMarriageJson = rawMarriageCookie;
initialProfile = getInitialMarriageProfile(parsed);
} catch {}
console.log("🖥️ [SSR Layout] Parsed rawMarriageCookie (non-decoded) successfully:", {
status: initialProfile?.status,
gender: initialProfile?.gender,
has_match_summary: Boolean(initialProfile?.match_summary),
match_summary_id: initialProfile?.match_summary?.id,
public_info_count: initialProfile?.match_summary?.public_info?.length,
});
} catch (e) {
console.warn("🖥️ [SSR Layout] Failed to parse rawMarriageCookie:", e);
}
}
} else {
console.log("🖥️ [SSR Layout] No rawMarriageCookie found in request cookies");
}
return (
<html

10
src/app/providers.tsx

@ -44,7 +44,17 @@ export default function Providers({ children, initialProfile }: ProvidersProps)
},
});
if (initialProfile) {
console.log("⚡ [Providers] Initializing QueryClient cache with SSR initialProfile:", {
id: initialProfile.id,
status: initialProfile.status,
gender: initialProfile.gender,
has_match_summary: Boolean(initialProfile.match_summary),
match_summary_id: initialProfile.match_summary?.id,
public_info_count: initialProfile.match_summary?.public_info?.length,
});
qc.setQueryData(marriageQueryKeys.profile(), initialProfile);
} else {
console.log("ℹ️ [Providers] No initialProfile passed from SSR");
}
return qc;
},

Loading…
Cancel
Save