Skip to content

draftMode gets disconnected #3064

@oscarcarlstrom

Description

@oscarcarlstrom

Draft mode gets disabled in presentation mode from time to time.

We upgraded to the latest versions of all our sanity-packages, and had to do a downgrade again because presentation mode disabled draft mode for the FE-app (used for visual editing). It only happened on some documents. The only thing they had in common was:

  1. The were quite large (had lots of data)
  2. They had both been created just before the upgrade

Steps to reproduce the behavior:

  1. Make sure to have a studio setup with a Next app where using <SanityLive/> and <VisualEditing /> for presentation mode.
  2. Make sure you have the following installed:
"@sanity/schema": "3.92.0",
 "@sanity/cli": "3.92.0",
"@sanity/ui": "2.15.18",
"@sanity/vision": "3.93.0",
"groq": "3.93.0",
"sanity": "3.93.0",
  1. Create some documents
  2. Make sure live editing works in presentation mode
  3. Upgrade to:
@sanity/schema": "3.93.0",
 "@sanity/cli": "3.93.0",
"@sanity/ui": "2.16.2",
"@sanity/vision": "3.93.0",
"groq": "3.93.0",
"sanity": "3.93.0",
  1. Try and edit the documents with visual editing in presentation mode

Editing the content should update the app that is viewed in draft mode. But what actually happens is that we get an error in the console stating something like:

"draftMode was enabled, but is now being disabled". The changes are not shown, and since the document is unpublished the app shows a 404 page (since the documents we noticed this issue for we not published)

Sanity versions:

"@sanity/schema": "3.93.0",
"@sanity/cli": "3.93.0",
"@sanity/ui": "2.16.2",
"@sanity/vision": "3.93.0",
"groq": "3.93.0",
"sanity": "3.93.0",

node: v22.13.1
pnpm: 10.12.1

The issue only seemed to appear in production. But it is hard to tell if the environment or dataset had anything to do with it, or if it was just the documents them selves which happened to be in the production dataset.

Any security issues should be submitted directly to [email protected]. In order to determine whether you are dealing with a security issue, ask yourself these two questions:

  • Can I access something that's not mine, or something I shouldn't have access to?
  • Can I disable something for other people? If the answer to either of those two questions are "yes", then you're probably dealing with a security issue. Note that even if you answer "no" to both questions, you may still be dealing with a security issue, so if you're unsure, just email us at [[email protected]](mailto:[email protected].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions