vercel/next.js · error · Error
Draft mode cannot be enabled during build-time instant…
Error message
Draft mode cannot be enabled during build-time instant validation.
What it means
Scope guard on the stub DraftModeProvider used during build-time instant validation: sampling renders run at build time where enabling draft mode is meaningless (there is no request cookie to set), so the provider always reports isEnabled: false and throws on enable() to reject any sampled code path that tries to flip it.
Solutions
- Do not enable draft mode during build-time instant validation; guard the call with a build-time check.
Defensive patterns
Strategy: validation
When it happens
Trigger: draftMode().enable() is called during build-time instant validation.
Common situations: Enabling draft mode inside code executed by the instant validation sampler at build time.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/e3470805cbf3a612.
Report an issue: GitHub.
Appendix: source
Thrown at packages/next/src/server/app-render/instant-validation/instant-samples.ts:238
return Reflect.get(target, prop, receiver)
},
})
}
/**
* Creates a DraftModeProvider that always returns isEnabled: false.
*/
export function createDraftModeForValidation(): DraftModeProvider {
// Create a minimal DraftModeProvider-compatible object
// that always reports draft mode as disabled.
//
// private properties that can't be set from outside the class.
return {
get isEnabled() {
return false
},
enable() {
throw new Error(
'Draft mode cannot be enabled during build-time instant validation.'
)
},
disable() {
throw new Error(
'Draft mode cannot be disabled during build-time instant validation.'
)
},
} as Partial<DraftModeProvider> as DraftModeProvider
}
/**
* Creates params wrapped with an exhaustive proxy.
* Accessing a param not declared in the sample will throw an error.
*/
export function createExhaustiveParamsProxy<TParams extends Params>(
underlyingParams: TParams,
declaredParamNames: Set<string>,View on GitHub (pinned to 0eb3775416)