Skip to content

User can publish during Autosave #6648

Closed

Description

@r1tsuu

Link to reproduction

No response

Payload Version

3.0.0-beta.37

Node Version

20

Next.js Version

14.68canary

Describe the Bug

A user can save a document during autosave. When transactions are used (with replicaSet and haven't tested Postgres but probably too) this causes race conditions, from logs:

[14:53:45] ERROR: There was an error cleaning up old versions for the collection projects
[14:53:45] ERROR: TypeError: Cannot read properties of undefined (reading 'version')

[14:53:45] ERROR: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction.
(MongoServerError)

We should disable the publish button during autosave

Reproduction Steps

Enable autosave in a collection/global config and try to publish a document during autosave.
And important to have replicaSet when using MongoDB (mongodb atlas or configured docker compose with it) either way transactions aren't used.

Adapters and Plugins

No response

Activity

  1. added
    status: needs-triage
    on Jun 5, 2024
  2. removed
    status: needs-triage
    on Jun 10, 2024
  3. PP-Tom commented on Dec 5, 2024

    @PP-Tom

    ERROR: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction. is still an issue and seems to be happening more since 3.4.0 with autosave.

  4. cgilly2fast commented on Dec 9, 2024

    @cgilly2fast

    Getting this error with autosave too, happens if I click publish too soon after making an update to my document:

    [21:30:29] ERROR: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction.
        err: {
          "type": "MongoServerError",
          "message": "Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction.",
          "stack":
              MongoServerError: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction
    .
                  at Connection.sendCommand (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/cmap/connection.js:290:27)
                  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
                  at async Connection.command (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/cmap/connection.js:317:26)
                  at async Server.command (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/sdam/server.js:167:29)
                  at async DeleteManyOperation.executeCommand (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/com
    mand.js:73:16)
                  at async DeleteManyOperation.execute (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/delete.js:
    48:21)
                  at async DeleteManyOperation.execute (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/delete.js:
    77:21)
                  at async tryOperation (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/execute_operation.js:199:
    20)
                  at async executeOperation (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/execute_operation.js:
    69:16)
                  at async Collection.deleteMany (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/collection.js:246:16)
                  at async model.Query.exec (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongoose/lib/query.js:4458:63)
                  at async Object.deleteMany (webpack-internal:///(rsc)/../../node_modules/.pnpm/@[email protected][email protected][email protected]_monaco-editor
    @[email protected]_yha243azqyq3umrsbkbsg4kqyi/node_modules/@payloadcms/db-mongodb/dist/deleteMany.js:17:5)
                  at async checkDocumentLockStatus (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected][email protected][email protected][email protected].
    [email protected][email protected][email protected]/node_modules/payload/dist/utilities/checkDocumentLockStatus.js:67:5)
                  at async updateByIDOperation (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected][email protected][email protected][email protected]_re
    [email protected][email protected][email protected]/node_modules/payload/dist/collections/operations/updateByID.js:117:9)
                  at async Object.updateByID (webpack-internal:///(rsc)/../../node_modules/.pnpm/@[email protected]_@[email protected][email protected]_monaco-editor
    @[email protected]_@b_xs3t2sptjkjswi3uod3b7u44ca/node_modules/@payloadcms/next/dist/routes/rest/collections/updateByID.js:35:15)
                  at async eval (webpack-internal:///(rsc)/../../node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_next@
    15.0.4_@b_xs3t2sptjkjswi3uod3b7u44ca/node_modules/@payloadcms/next/dist/routes/rest/index.js:760:19)
                  at async AppRouteRouteModule.do (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected].
    [email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:10:33313)
                  at async AppRouteRouteModule.handle (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@opentelemetry+api@
    [email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:10:40382)
                  at async doRender (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_babel-plugin
    [email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:1455:42)
                  at async responseGenerator (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_bab
    [email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:1814:28)
                  at async DevServer.renderToResponseWithComponentsImpl (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@
    [email protected][email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:1824:28)
                  at async DevServer.renderPageComponent (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@opentelemetry+a
    [email protected][email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:2240:24)
                  at async DevServer.renderToResponseImpl (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@opentelemetry+
    [email protected][email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:2278:32)
                  at async DevServer.pipeImpl (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_ba
    [email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:960:25)
                  at async NextNodeServer.handleCatchallRenderRequest (/Users/colbygilb PATCH /api/queries/67569b9c921923fa2cff2cb5?draft=true&autosave=true&locale=unde
    fined
    
  5. github-actions commented on Mar 4, 2025

    @github-actions
    Contributor

    🚀 This is included in version v3.26.0

  6. github-actions commented on Mar 12, 2025

    @github-actions
    Contributor

    This issue has been automatically locked.
    Please open a new issue if this issue persists with any additional detail.

  7. locked as resolved and limited conversation to collaborators on Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions