Skip to content

[Bug] "Cannot destructure property 'path' of 'this.parent'" error when the document reloads or is undone while an image resize handle is held #5394

Closed

Description

@Jocs

Description

If the document is reloaded from disk, or an undo runs, while an image resize handle is held, releasing the mouse button opens the "Unexpected renderer process error" dialog and the resize is discarded. It needs specific timing (a sync tool, git or another editor writing the file mid-drag, or pressing Undo while holding the button), but then it happens every time. In the undo case, Auto Save also writes the undone text back to disk.

Steps to Reproduce

  1. Put pic.png (400×300) in a folder, and next to it create doc.md:
    # Title
    
    Some text before the image.
    
    ![](pic.png)
    
    Text after the image.
  2. Open doc.md in MarkText, turn on File > Auto Save and check that it shows a checkmark. Without Auto Save the external change is not reloaded and nothing goes wrong.
  3. Click the image so the resize handles appear.
  4. Press and hold the right handle and drag it about 40 px to the left.
  5. While still holding the button, open doc.md in another editor, replace Some text before the image. with Changed on disk. and save it there.
  6. Keep holding the button for 2–3 seconds until MarkText shows Changed on disk.. The image snaps back to 400 px and the handles jump to the window's top-left corner.
  7. Drag a little more and release the button.

Undo variant: after step 2, change the file on disk once and wait until MarkText reloads it. Then do steps 3–4, and while holding the handle press Cmd+Z (Edit > Undo) instead of changing the file. Release the button. The undo was confirmed through the Edit > Undo action; the key press while holding the button was not checked separately.

Expected Behavior

The resize either applies to the reloaded document or is cancelled quietly. No error dialog appears.

Actual Behavior

  • When MarkText reloads the file mid-drag, the image snaps back to 400 px and both handles move to the window's top-left corner while the button is still held.
  • On release, one "Unexpected renderer process error" dialog opens with TypeError: Cannot destructure property 'path' of 'this.parent' as it is null.
  • The image stays at 400 px, the handles are gone, and no width is saved: the file keeps ![](pic.png) together with the external text.
  • Undo variant: the same single error on release and no width saved. The undo also reverts the reloaded text to Some text before the image., and Auto Save writes that reverted text to disk.

Screenshots / Logs

TypeError: Cannot destructure property 'path' of 'this.parent' as it is null.
    at get path (index-_m8tBt4l.js:108465:19)
    at get path (index-_m8tBt4l.js:97349:19)
    at set text (index-_m8tBt4l.js:97358:19)
    at ParagraphContent.updateImage (index-_m8tBt4l.js:98063:15)
    at HTMLBodyElement._mouseUp (index-_m8tBt4l.js:155043:19)

Operating System

macOS

MarkText Version

0.20.0-rc.3 (also reproduced on the current develop branch)

OS Version

macOS 27.0 (arm64)

Reproducibility

  • I can reliably reproduce this issue

Related

Possible cause (unverified): a reload, or an undo across a reload, rebuilds the block tree, but ImageResizeBar (packages/muya/src/ui/imageResizeBar/index.ts) keeps _block and _imageInfo from the old, detached block. On release, _mouseUp → updateImage sets that block's text, and reading its path throws on the null parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bug🔭 area/muya🚧 needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions