ianstormtaylor/slate · error · Error

Cannot enter non-chunk

Error message

Cannot enter non-chunk

What it means

Internal invariant of slate-react's chunk tree helper: enterChunk() requires the current pointer node to be of type 'chunk' before descending into it. It is only called from enterChunkUntilLeaf after checking the node type, so reaching this throw means internal state is inconsistent (an 'istanbul ignore next' defensive branch).

Source

Thrown at packages/slate-react/src/chunking/chunk-tree-helper.ts:421

    this.pointerChunk = chunk
    this.pointerIndex = index
    this.pointerIndexStack = indexStack
    this.reachedEnd = false
    this.cachedPointerNode = node
    this.validateState()
  }

  /**
   * Assuming the current node is a chunk, move the pointer into that chunk
   *
   * @param end If true, place the pointer on the last node of the chunk.
   * Otherwise, place the pointer on the first node.
   */
  private enterChunk(end: boolean) {
    // istanbul ignore next
    if (this.pointerNode?.type !== 'chunk') {
      throw new Error('Cannot enter non-chunk')
    }

    this.pointerIndexStack.push(this.pointerIndex)
    this.pointerChunk = this.pointerNode
    this.pointerIndex = end ? this.pointerSiblings.length - 1 : 0
    this.cachedPointerNode = undefined
    this.validateState()

    // istanbul ignore next
    if (this.pointerChunk.children.length === 0) {
      throw new Error('Cannot enter empty chunk')
    }
  }

  /**
   * Assuming the current node is a chunk, move the pointer into that chunk
   * repeatedly until the current node is a leaf
   *

View on GitHub (pinned to 72a37c701e)

Solutions

  1. Upgrade slate-react to the latest version
  2. Report the bug upstream with a reproduction
  3. Audit any local changes to chunk-tree-helper call sites
Defensive patterns

Strategy: retry

Try / catch

try {
  edit()
} catch (e) {
  if (e.message === 'Cannot enter non-chunk') {
    // internal bug: remount the editor as recovery
  } else throw e
}

Prevention

When it happens

Trigger: Internal library bug or corrupted chunk-tree state; not producible through the public slate-react API.

Common situations: Buggy slate-react versions with chunking regressions; direct manipulation of internal chunk state in forks.

Related errors


AI-assisted analysis of ianstormtaylor/slate@72a37c701e (2026-08-27). Data as JSON: /api/errors/696232a2c87027f3. Report an issue: GitHub.