vercel/next.js · error · Error

Draft mode cannot be disabled during build-time instant…

Error message

Draft mode cannot be disabled during build-time instant validation.

What it means

Scope guard on the validation-time DraftModeProvider: disable() was called during build-time instant validation. As with enable(), draft mode state cannot be mutated in a sampling render, so the stub rejects the mutation while still reporting isEnabled: false.

Solutions

  1. Do not disable draft mode during build-time instant validation; guard the call with a build-time check.
Defensive patterns

Strategy: validation

When it happens

Trigger: draftMode().disable() is called during build-time instant validation.

Common situations: Disabling 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/c1676227d8ef7f8e. Report an issue: GitHub.

Appendix: source

Thrown at packages/next/src/server/app-render/instant-validation/instant-samples.ts:243

/**
 * 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>,
  route: string
): TParams {
  return new Proxy(underlyingParams, {
    get(target, prop, receiver) {
      if (

View on GitHub (pinned to 0eb3775416)