Skip to content

fix(muyajs): null-guard list block paths to prevent renderer crash (#4346) - #4359

Merged
Jocs merged 1 commit into
developfrom
fix/4346-list-block-null-guards
Jun 3, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/4346-list-block-null-guards

Conversation

@Jocs

@Jocs Jocs commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

Root cause

When a list item is mutated (Backspace through empty list, task-list <-> bullet transitions, paste empty <ul></ul>) the contentState transiently holds references to blocks whose children array is empty or whose startBlock has been removed. Three sites destructured / read fields on the resulting null:

  • packages/muyajs/lib/utils/exportMarkdown.js ul/ol case destructured block.children[0] -> the originally reported Cannot destructure property 'bulletMarkerOrDelimiter' of 'block2.children[0]' as it is undefined
  • packages/muyajs/lib/contentState/formatCtrl.js selectionFormats destructured text from a null startBlock
  • packages/muyajs/lib/contentState/backspaceCtrl.js backspaceHandler read .type from a null block

Each site now short-circuits when its block is missing, deferring to the next selection-change cycle once state settles.

Closes

Closes #4346

Test plan

  • pnpm -C packages/desktop exec playwright test test/e2e/issue-4346.spec.ts -- 4/4 pass with this PR (verified red without the fix)
  • Existing crash regression guards still green: crash-range-offset.spec.ts, crash-selection-change.spec.ts, crash-update-paragraph.spec.ts
  • Editor input / inline-format / paragraph-blocks e2e suites still green
  • pnpm run typecheck clean

Generated with Claude Code

…4346)

When a list item is mutated (Backspace through empty list, task-list <-> bullet
transitions, paste empty <ul></ul>) the contentState transiently holds
references to blocks whose children array is empty or whose startBlock has
been removed. Three sites destructured / read fields on the resulting null:

- exportMarkdown.js ul/ol case destructured block.children[0]
- formatCtrl.selectionFormats destructured text from a null startBlock
- backspaceCtrl.backspaceHandler read .type from a null block

Add null guards at each site. Adjacent-stack reproduction guarded by
packages/desktop/test/e2e/issue-4346.spec.ts (task-list -> bullet-list
backspace recipe).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Website preview ready: https://pr-4359-marktext-website.ransixi.workers.dev

Built from 194750d868fa38e529fb95b699d5990dbd8181cf · Worker: marktext-website · Version: 1e3e7709-33bc-46c7-9046-fd5e57c8f653 · Alias: pr-4359

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Build artifacts for PR #4359:

Run: https://github.com/marktext/marktext/actions/runs/26892918987

Artifact Size Link
marktext-windows-arm64 270.6 MB Download
marktext-linux 592.9 MB Download
marktext-macos-x64 271.7 MB Download
marktext-windows-x64 271.9 MB Download
marktext-macos-arm64 261.4 MB Download

@Jocs
Jocs merged commit 056f12d into develop Jun 3, 2026
11 checks passed
@Jocs
Jocs deleted the fix/4346-list-block-null-guards branch June 10, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected error with message Cannot destructure property 'bulletMarkerOrDelimiter' of 'block2.children[0]' as it is undefined.

1 participant