Troubleshooting
Diagnose DEFER_* errors without guessing host capabilities.
Hit a DEFER_* error? Match the code below. Public defer failures use
CruxDeferError with a stable code and docsUrl
(https://cruxjs.dev/docs/errors/<CODE>).
import { CruxDeferError, defer } from '@use-crux/core'
try {
defer(() => {})
} catch (error) {
if (error instanceof CruxDeferError) {
console.error(error.code, error.docsUrl)
}
}Quick map
| Code | Typical cause |
|---|---|
DEFER_SCOPE_REQUIRED | No active invocation scope (missing host wrapper) |
DEFER_CAPABILITY_MISSING | Scope exists but cannot support this overload (inline unsupported, missing waitUntil/after, named without durable finalization) |
DEFER_SCOPE_SEALED | Registration after seal |
DEFER_LIMIT_EXCEEDED | Callback count/nesting/concurrency bounds |
DEFER_REPLAY_UNSAFE | Public defer() inside a replayable flow, use flow.defer() |
DEFER_TARGET_INPUT_REQUIRED | Named target called without required JSON input |
DEFER_COMMIT_FAILED | Strict named staging/finalization failed; response discarded |
Runtime-bound failures still use Runtime codes such as
RUNTIME_REQUIRED.
Checklist
- Is the handler wrapped (
withNodeDefer,withNextDefer,withWaitUntilDefer, Convexbridge.run, …)? - For inline work: does the host advertise a real lifetime capability?
- For named work: is
config({ runtime })present and isdurableFinalization: trueon the host lifetime? - Inside flows: use
flow.defer(), never publicdefer(). - Catching a named
deferpromise does not undoDEFER_COMMIT_FAILED; fix the staging failure or use the callback overload for best-effort work.
Project Index lints
Static analysis reports:
defer.replay_unsafedefer.floating_named_promisedefer.missing_scope
Named calls without Runtime also reuse runtime.missing_runtime_config when
the analyzer can tell for sure from your code. Static analysis cannot always
determine host capability; the runtime still throws DEFER_CAPABILITY_MISSING
when the live host cannot honor the call.
Check project setup
Run crux setup for a read-only aggregate check, or crux setup --apply to
apply safe additive Runtime resources and recheck. The defer contributor reports
missing host integrations and named-durability configuration with exact
remediation and a privacy-safe coding-agent prompt. Lifetime capability is
still verified at the live host boundary; having a package installed does not
by itself mean the host supports defer.
See Project setup for modes and JSON output.