{"record":{"id":"f2c2db89c87b0b6c","repo":"unionlabs/union","slug":"user-is-not-logged-in","errorCode":null,"errorMessage":"User is not logged in","messagePattern":"User is not logged in","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ceremony/src/lib/supabase/index.ts","lineNumber":32,"sourceCode":"  queryUserPublicHash,\n  queryUserQueuePosition,\n  queryUserWallet,\n  queryVerificationTime,\n} from \"$lib/supabase/queries.ts\"\nimport { msToTimeString, sleep, timeToMs } from \"$lib/utils/utils.ts\"\n\nexport interface TimeResult {\n  verification: string | null\n  contribution: string | null\n  total: string\n  verificationMs: number\n  contributionMs: number\n  totalMs: number\n}\n\nexport const callJoinQueue = async (code: string | null): Promise<boolean> => {\n  if (!user.session) {\n    throw new Error(\"User is not logged in\")\n  }\n  const userId = user.session.user.id\n  if (!userId) {\n    throw new Error(\"User is not logged in\")\n  }\n\n  try {\n    const { error } = await supabase.rpc(\"join_queue\", { code_id: code })\n\n    if (error) {\n      console.log(\"Error joining queue:\", error)\n      return false\n    }\n\n    return true\n  } catch (err) {\n    console.log(\"Unexpected error:\", err)\n    return false","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/unionlabs/union/blob/031785bb6dc6b957c624e62bc64c184409c97d7b/ceremony/src/lib/supabase/index.ts#L14-L50","documentation":"First guard in callJoinQueue: the ceremony app's reactive Supabase user store has no session (user.session is null), so there is no authenticated user to join the signing-queue RPC. The function throws instead of returning its boolean failure path, so callers must ensure auth before invoking.","triggerScenarios":"Calling callJoinQueue before login finishes, after session expiry (idle JWT timeout), or on a hard refresh where the user store has not yet hydrated the restored session.","commonSituations":"Race between Supabase auth restoration (INITIAL_SESSION via onAuthStateChange) and UI button handlers; expired JWT after a long-idle tab; logout performed in another tab.","solutions":["Ensure supabase.auth.getSession() has resolved and user.session is populated before rendering/enabling the join-queue action","On app boot, await the INITIAL_SESSION event before calling session-dependent APIs","Redirect the user to login (or trigger supabase.auth.signIn) and retry after authentication"],"exampleFix":"// before\nawait callJoinQueue(code)\n\n// after\nconst { data: { session } } = await supabase.auth.getSession()\nif (!session) {\n  await goto(\"/login\")\n  return\n}\nawait callJoinQueue(code)","handlingStrategy":"validation","validationCode":"const { data: { session } } = await supabase.auth.getSession()\nif (!session) {\n  await goto(\"/login\")\n  return\n}\nawait callJoinQueue(code)","typeGuard":null,"tryCatchPattern":"try {\n  await callJoinQueue(code)\n} catch (e) {\n  if (e instanceof Error && e.message === \"User is not logged in\") {\n    await goto(\"/login?redirect=/queue\")\n    return\n  }\n  throw e\n}","preventionTips":["Await the INITIAL_SESSION event on boot before enabling auth-dependent actions","Gate queue actions on an authenticated store flag","Subscribe to onAuthStateChange SIGNED_OUT to stop in-flight flows"],"tags":["auth","supabase","ceremony"],"backgroundTag":null,"analyzedSha":"031785bb6dc6b957c624e62bc64c184409c97d7b","analyzedAt":"2026-08-16T06:24:09.996Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}