Skip to content
Latchkey

Remix loader/action did not return a Response in CI

A Remix loader or action must return data (via json) or a Response (via redirect, defer, or a raw Response). Returning undefined throws at request time, and type-checking in CI catches many of these before they ship.

What this error means

The app throws "You defined a loader/action for route X but did not return anything", or remix build/tsc fails on a loader whose return type is not assignable.

remix
Error: You defined a loader for route "routes/dashboard" but didn't return
anything from your `loader` function. Please return a value or `null`.

Common causes

A code path with no return

A branch in the loader/action (an early guard, a caught error) falls through without returning json, redirect, or null.

An async function that never resolves data

The loader awaits work but forgets to return the result, so the function resolves to undefined.

How to fix it

Return json, redirect, or null on every path

  1. Ensure each branch returns json(...), a redirect(...), or explicit null.
  2. Type the loader with LoaderFunctionArgs so CI type-checks the return.
  3. Re-run the build to confirm the return type is satisfied.
app/routes/dashboard.tsx
export async function loader({ request }: LoaderFunctionArgs) {
  const user = await getUser(request);
  if (!user) return redirect("/login");
  return json({ user });
}

Type-check in CI to catch it early

Add a tsc --noEmit step so a loader missing a return fails the build instead of the running app.

.github/workflows/ci.yml
npx tsc --noEmit

How to prevent it

  • Always return json, redirect, defer, or null from loaders/actions.
  • Use the typed LoaderFunctionArgs/ActionFunctionArgs signatures.
  • Run tsc --noEmit in CI to catch missing returns.

Frequently asked questions

What causes "loader/action must return data"?
A branch in the loader/action (an early guard, a caught error) falls through without returning json, redirect, or null.
How do I fix loader/action must return data?
Return json, redirect, or null on every path

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card