unionlabs/union · error · Error

User is not logged in

Error message

User is not logged in

What it means

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.

Solutions

  1. Ensure supabase.auth.getSession() has resolved and user.session is populated before rendering/enabling the join-queue action
  2. On app boot, await the INITIAL_SESSION event before calling session-dependent APIs
  3. Redirect the user to login (or trigger supabase.auth.signIn) and retry after authentication

Example fix

// before
await callJoinQueue(code)

// after
const { data: { session } } = await supabase.auth.getSession()
if (!session) {
  await goto("/login")
  return
}
await callJoinQueue(code)
Defensive patterns

Strategy: validation

Validate before calling

const { data: { session } } = await supabase.auth.getSession()
if (!session) {
  await goto("/login")
  return
}
await callJoinQueue(code)

Try / catch

try {
  await callJoinQueue(code)
} catch (e) {
  if (e instanceof Error && e.message === "User is not logged in") {
    await goto("/login?redirect=/queue")
    return
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of unionlabs/union@031785bb6d (2026-08-16). Data as JSON: /api/errors/f2c2db89c87b0b6c. Report an issue: GitHub.

Appendix: source

Thrown at ceremony/src/lib/supabase/index.ts:32

  queryUserPublicHash,
  queryUserQueuePosition,
  queryUserWallet,
  queryVerificationTime,
} from "$lib/supabase/queries.ts"
import { msToTimeString, sleep, timeToMs } from "$lib/utils/utils.ts"

export interface TimeResult {
  verification: string | null
  contribution: string | null
  total: string
  verificationMs: number
  contributionMs: number
  totalMs: number
}

export const callJoinQueue = async (code: string | null): Promise<boolean> => {
  if (!user.session) {
    throw new Error("User is not logged in")
  }
  const userId = user.session.user.id
  if (!userId) {
    throw new Error("User is not logged in")
  }

  try {
    const { error } = await supabase.rpc("join_queue", { code_id: code })

    if (error) {
      console.log("Error joining queue:", error)
      return false
    }

    return true
  } catch (err) {
    console.log("Unexpected error:", err)
    return false

View on GitHub (pinned to 031785bb6d)