Skip to content

Unpublishing drops unsaved edits, and the next save after an unpublish or a discard is refused as a conflict #3089

Description

@danielmlr

Description

After unpublishing a post or discarding its draft, the editor's next save is refused as a conflict with that same action. Unpublishing also throws away whatever autosave had not sent yet.

Both actions bump the entry's version and the server returns the new _rev, but the admin does not read it. Since #2860 the editor no longer takes its token from the reloaded entry: it reads it once when it opens the entry and then updates it from its own saves, publishes and schedules. So the next save goes out with the old token, gets a 409, and the editor shows "This entry changed somewhere else after you opened it." Publish saves first, so clicking Publish right after an unpublish fails the same way and the post stays unpublished. That is how a writer would undo the misclick #2517 describes. Restoring a revision from the sidebar returns a new _rev that is not read either, so it leaves the same stale token.

Unpublishing also reloads the entry without saving first, so the reloaded copy replaces the unsent edits and the header reads "Saved". It is the reset #2965 reported for the publication date, which publish, schedule and the date control avoid by saving pending changes before they write.

Reading the new token from these responses, and saving pending changes before unpublishing, closes both. I have tests and a fix for unpublish and discard.

I think this belongs under the "manual save, autosave, and publish do not race" criterion in #1683. Its scope lists unpublish and discard, and the editor's save-ordering tests do not cover them.

Steps to reproduce

  1. In a collection that supports drafts and revisions, open a published post that has no pending changes.
  2. Click "Unpublish Post".
  3. Type one character into the title and wait two seconds for autosave.
  4. The autosave request gets a 409 and the banner appears.

The same happens after "Discard changes" on a post with draft changes, and after restoring an older revision from the Revisions panel. Clicking "Publish now" right after step 2 fails the same way, and the post stays unpublished.

For the lost edits: open a published post, type into the title, and click "Unpublish Post" within two seconds. The typed text disappears, the header reads "Saved", and no save request is sent.

Environment

  • emdash version: 0.37.0, and the same on main at b581ff8
  • Node.js version: 26.8.1
  • Runtime: Node (@astrojs/node, astro dev)
  • OS: macOS

Screenshots

Admin editor after unpublishing a post and typing one character: a red banner reads "This entry changed somewhere else after you opened it." with a "Save anyway" button, and the sidebar shows a draft version

Logs / error output

# Requests after unpublishing and typing one character; _rev decoded from base64
POST /_emdash/api/content/posts/<id>/unpublish  200  sent: no body         returned _rev 7:2026-09-12T22:03:51.140Z
GET  /_emdash/api/content/posts/<id>            200                         returned _rev 7:2026-09-12T22:03:51.140Z
PUT  /_emdash/api/content/posts/<id>            409  sent _rev 6:2026-09-12T22:03:33.890Z
     "Content has been modified since last read (version conflict)"

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions