Skip to content

fix(saver): propagate save failures to callers - #3061

Closed
neSpecc wants to merge 3 commits into
nextfrom
cursor/finish-pr-3033-64c2
Closed

neSpecc wants to merge 3 commits into
nextfrom
cursor/finish-pr-3033-64c2

Conversation

@neSpecc

@neSpecc neSpecc commented Nov 27, 2026

Copy link
Copy Markdown
Member

This PR supersedes #3033 (opened by @Sion612) and completes the outstanding review items.

Changes

Original work by @Sion612:

Additional fixes:

  • Modified readOnly.toggle() to restore editor to consistent state if save fails: when the save throws, the editor is restored to its previous read-only state (wraps save in try-catch, restores state on error)
  • Added Cypress test verifying that after a failed readOnly.toggle(), the editor is not in read-only mode and editor.save() works once the failure is gone
  • Added CHANGELOG entries under 2.32.0 for both fixes

Why this PR supersedes #3033

The original PR branch couldn't be updated because push access to the fork Sion612/editor.js was not available through the maintainer edit permissions. This PR preserves the original author's commit and authorship, adds the requested fixes on top, and rebases everything onto the current next branch.

Testing

All lints and relevant Cypress specs pass:

  • ✅ Saver module tests (6 passing)
  • ✅ ReadOnly API spec tests (4 passing)

Fixes #3030

Open in Web Open in Cursor 

Sion612 and others added 3 commits November 27, 2026 14:50
When readOnly.toggle() calls Saver.save() and it throws (now that #3030
makes save failures propagate), the editor was left flagged as read-only
while blocks remained editable. This commit wraps the save call in
try-catch and restores the previous read-only state on error.

Adds Cypress test covering: a tool whose save throws, so readOnly.toggle()
rejects; afterwards the editor isn't read-only and editor.save() works
once the failure is gone.

Co-authored-by: Peter <neSpecc@users.noreply.github.com>
Extract the loop that calls toggleReadOnly on all Editor modules into
a private method to eliminate duplication between the normal toggle
path and the error recovery path.

Co-authored-by: Peter <neSpecc@users.noreply.github.com>
@neSpecc neSpecc closed this Nov 27, 2026
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.

Silent Data Loss & Broken Error Contract in Saver.save()

3 participants