ianstormtaylor/slate · error · Error

Cannot save pointer when pointerNode is null

Error message

Cannot save pointer when pointerNode is null

What it means

An internal invariant of the chunk tree helper used by slate-react's chunked rendering (performance feature for very large documents). savePointer() snapshots the current pointer position; if the pointer is not at 'start' the pointerNode must exist. This throw is marked 'istanbul ignore next' — it should be unreachable unless there is a bug in the library itself or internal state was corrupted.

Source

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

      if (index === -1) {
        return null
      }

      path.unshift(index)
    }

    return path
  }

  /**
   * Save the current pointer to be restored later
   */
  private savePointer(): SavedPointer {
    if (this.atStart) return 'start'

    // istanbul ignore next
    if (!this.pointerNode) {
      throw new Error('Cannot save pointer when pointerNode is null')
    }

    return {
      chunk: this.pointerChunk,
      node: this.pointerNode,
    }
  }

  /**
   * Restore the pointer to a previous state
   */
  private restorePointer(savedPointer: SavedPointer) {
    if (savedPointer === 'start') {
      this.pointerChunk = this.root
      this.pointerIndex = -1
      this.pointerIndexStack = []
      this.reachedEnd = false
      this.cachedPointerNode = undefined

View on GitHub (pinned to 72a37c701e)

Solutions

  1. Update slate-react to the latest patch version
  2. Report the issue to the Slate repo with a minimal reproduction if it persists on the latest version
  3. If you maintain a fork, audit rawInsertPointer/insertAfter for state mutation that clears pointerNode before savePointer
Defensive patterns

Strategy: retry

Try / catch

try {
  renderLargeDocument()
} catch (e) {
  if (e.message.includes('Cannot save pointer')) {
    // internal bug: report upstream, retry after re-render
    requestAnimationFrame(renderLargeDocument)
  } else throw e
}

Prevention

When it happens

Trigger: Internal library bug or corrupted internal state during rawInsertPointer/insertAfter in chunked rendering; essentially unreachable through the public API.

Common situations: Hacking on slate-react internals; a genuinely buggy slate-react version with a chunking regression on huge documents.

Related errors


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