Expose machine context debug info in console
This commit is contained in:
parent
0fb95147f4
commit
a1bd3bb7b9
1 changed files with 24 additions and 0 deletions
|
|
@ -43,6 +43,12 @@ type MachineContextError = {
|
||||||
details?: Record<string, unknown> | null
|
details?: Record<string, unknown> | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
__machineContextDebug?: unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const authClient = createAuthClient({
|
const authClient = createAuthClient({
|
||||||
plugins: [customSessionClient<AppAuth>()],
|
plugins: [customSessionClient<AppAuth>()],
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
|
|
@ -124,6 +130,16 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||||
const message =
|
const message =
|
||||||
(payload && typeof payload.error === "string" && payload.error.trim()) || fallbackMessage
|
(payload && typeof payload.error === "string" && payload.error.trim()) || fallbackMessage
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
|
const debugPayload = {
|
||||||
|
status: response.status,
|
||||||
|
message,
|
||||||
|
payload,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
}
|
||||||
|
console.error("[auth] machine context request failed", debugPayload)
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
window.__machineContextDebug = debugPayload
|
||||||
|
}
|
||||||
setMachineContext(null)
|
setMachineContext(null)
|
||||||
setMachineContextError({
|
setMachineContextError({
|
||||||
status: response.status,
|
status: response.status,
|
||||||
|
|
@ -160,6 +176,14 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to load machine context", error)
|
console.error("Failed to load machine context", error)
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
|
const debugPayload = {
|
||||||
|
error: error instanceof Error ? { name: error.name, message: error.message, stack: error.stack } : String(error),
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
}
|
||||||
|
console.error("[auth] machine context unexpected error", debugPayload)
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
window.__machineContextDebug = debugPayload
|
||||||
|
}
|
||||||
setMachineContext(null)
|
setMachineContext(null)
|
||||||
setMachineContextError({
|
setMachineContextError({
|
||||||
status: 0,
|
status: 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue