{"record":{"id":"f2304a3826cf3bb6","repo":"ianstormtaylor/slate","slug":"cannot-enter-empty-chunk","errorCode":null,"errorMessage":"Cannot enter empty chunk","messagePattern":"Cannot enter empty chunk","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/slate-react/src/chunking/chunk-tree-helper.ts","lineNumber":432,"sourceCode":"   *\n   * @param end If true, place the pointer on the last node of the chunk.\n   * Otherwise, place the pointer on the first node.\n   */\n  private enterChunk(end: boolean) {\n    // istanbul ignore next\n    if (this.pointerNode?.type !== 'chunk') {\n      throw new Error('Cannot enter non-chunk')\n    }\n\n    this.pointerIndexStack.push(this.pointerIndex)\n    this.pointerChunk = this.pointerNode\n    this.pointerIndex = end ? this.pointerSiblings.length - 1 : 0\n    this.cachedPointerNode = undefined\n    this.validateState()\n\n    // istanbul ignore next\n    if (this.pointerChunk.children.length === 0) {\n      throw new Error('Cannot enter empty chunk')\n    }\n  }\n\n  /**\n   * Assuming the current node is a chunk, move the pointer into that chunk\n   * repeatedly until the current node is a leaf\n   *\n   * @param end If true, place the pointer on the last node of the chunk.\n   * Otherwise, place the pointer on the first node.\n   */\n  private enterChunkUntilLeaf(end: boolean) {\n    while (this.pointerNode?.type === 'chunk') {\n      this.enterChunk(end)\n    }\n  }\n\n  /**\n   * Move the pointer to the parent chunk","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/ianstormtaylor/slate/blob/72a37c701e5da4bb13a305d416d9c070d19d3a45/packages/slate-react/src/chunking/chunk-tree-helper.ts#L414-L450","documentation":"Internal invariant of slate-react's chunk tree helper: enterChunk() refuses to descend into a chunk with zero children because there would be no valid pointer position inside it. The branch is marked 'istanbul ignore next' — it guards against internal state corruption, since normal invariants prevent empty chunks from being entered.","triggerScenarios":"Internal bug or corrupted state leading to an empty chunk being entered during chunked rendering; not reachable via public APIs.","commonSituations":"Slate-react chunking regressions; forks that splice chunk children without maintaining invariants.","solutions":["Update slate-react","Report an upstream issue with a reproduction","Check fork code that empties chunk children arrays"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  edit()\n} catch (e) {\n  if (e.message === 'Cannot enter empty chunk') {\n    // internal bug: trigger a full reconciliation pass\n  } else throw e\n}","preventionTips":["Update slate-react","Ensure documents never contain structural anomalies like empty nested chunks"],"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"}