Crux
Errors

DEFER_SCOPE_REQUIRED

defer() was called without a Crux execution scope or ambient host binding.

What failed

defer() was called where no Crux primitive scope or ambient-capable host binding was active.

Why

Crux must know which execution boundary owns the work. Without a scope or host binding, it cannot establish drain timing, retention, limits, or cancellation. It throws instead of silently dropping the registration.

Fix

Run crux setup --check for the exact host-specific remediation, then choose the smallest matching rung:

  1. Move the call inside a Crux agent, adapter, tool, Safety session, or other defer-capable primitive.
  2. On Next or Vercel, add the platform binding to config({ host }).
  3. On Workers, use a per-request boundary with the current ctx.
  4. Add a strict wrapper when handler outcome or response commitment must be part of the same invocation.
crux.config.ts
import { config } from "@use-crux/core";
import { next } from "@use-crux/next";

export default config({ host: next() });

Inside replayable flow execution, use flow.defer() instead.

See Host support and Troubleshooting.

On this page