Repository navigation
Description
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
- Put
pic.png(400×300) in a folder, and next to it createdoc.md:# Title Some text before the image.  Text after the image.
- Open
doc.mdin 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. - Click the image so the resize handles appear.
- Press and hold the right handle and drag it about 40 px to the left.
- While still holding the button, open
doc.mdin another editor, replaceSome text before the image.withChanged on disk.and save it there. - 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. - 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
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
- Open PR fix(muya): start an image resize only from the resize bar's own handles (#5116) #5382 (for [Bug] Unexpected error with message Cannot read properties of null (reading 'querySelector') #5116) reaches the same error from
ParagraphContent.updateImageon a detached block through a different route (a drag started on content with the classbar, in another tab) and makes a resize start only from the bar's own handles. It does not cover a reload or undo during a drag on a real handle. - Unexpected error with message Cannot destructure property 'path' of 'this.parent' as it is null. #5055, Unexpected error with message Cannot destructure property 'path' of 'this.parent' as it is null. #5163, Unexpected error with message Cannot destructure property 'path' of 'this.parent' as it is null. #5213 and Unexpected error with message Cannot destructure property 'path' of 'this.parent' as it is null. #5215 (closed) have the same message from other code paths (image delete, search, quick insert).
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.
Activity
fix(muya): cancel image resize when the document rebuilds (#5394)
fix(muya): cancel image resize when the document rebuilds (#5394) (#5721