{"record":{"id":"c01d076d51fdb8ca","repo":"ianstormtaylor/slate","slug":"cannot-save-pointer-when-pointernode-is-null","errorCode":null,"errorMessage":"Cannot save pointer when pointerNode is null","messagePattern":"Cannot save pointer when pointerNode is null","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/slate-react/src/chunking/chunk-tree-helper.ts","lineNumber":358,"sourceCode":"      if (index === -1) {\n        return null\n      }\n\n      path.unshift(index)\n    }\n\n    return path\n  }\n\n  /**\n   * Save the current pointer to be restored later\n   */\n  private savePointer(): SavedPointer {\n    if (this.atStart) return 'start'\n\n    // istanbul ignore next\n    if (!this.pointerNode) {\n      throw new Error('Cannot save pointer when pointerNode is null')\n    }\n\n    return {\n      chunk: this.pointerChunk,\n      node: this.pointerNode,\n    }\n  }\n\n  /**\n   * Restore the pointer to a previous state\n   */\n  private restorePointer(savedPointer: SavedPointer) {\n    if (savedPointer === 'start') {\n      this.pointerChunk = this.root\n      this.pointerIndex = -1\n      this.pointerIndexStack = []\n      this.reachedEnd = false\n      this.cachedPointerNode = undefined","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/ianstormtaylor/slate/blob/72a37c701e5da4bb13a305d416d9c070d19d3a45/packages/slate-react/src/chunking/chunk-tree-helper.ts#L340-L376","documentation":"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.","triggerScenarios":"Internal library bug or corrupted internal state during rawInsertPointer/insertAfter in chunked rendering; essentially unreachable through the public API.","commonSituations":"Hacking on slate-react internals; a genuinely buggy slate-react version with a chunking regression on huge documents.","solutions":["Update slate-react to the latest patch version","Report the issue to the Slate repo with a minimal reproduction if it persists on the latest version","If you maintain a fork, audit rawInsertPointer/insertAfter for state mutation that clears pointerNode before savePointer"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  renderLargeDocument()\n} catch (e) {\n  if (e.message.includes('Cannot save pointer')) {\n    // internal bug: report upstream, retry after re-render\n    requestAnimationFrame(renderLargeDocument)\n  } else throw e\n}","preventionTips":["Keep slate-react up to date","Report internal-invariant errors to the Slate repo with a reproduction"],"tags":["slate-react","chunking","internal-invariant","unreachable"],"backgroundTag":"library-internal-invariant","analyzedSha":"72a37c701e5da4bb13a305d416d9c070d19d3a45","analyzedAt":"2026-08-27T23:04:51.145Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}