payload icon indicating copy to clipboard operation
payload copied to clipboard

Autosave makes it impossible to create new (localized) documents

Open mattiaz9 opened this issue 1 year ago • 4 comments

Link to reproduction

No response

Environment Info

Binaries:
  Node: 20.12.2
  npm: 10.5.0
  Yarn: N/A
  pnpm: 9.10.0
Relevant Packages:

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:04 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 12

Describe the Bug

When creating a new document with autosave enabled, it creates a new document instantly, but not the relative localized fields records. This causes an instantaneous redirect to the /doc/{id} page that shows a not found message. I can see in the database a new record in the main document table, but not in the relative _locales table.

This a new bug that I personally encountered recently, either after upgrading to one of the latest beta or when I changed the idType to uuid.

Reproduction Steps

  1. enable autosave in the collection config:
...
versions: {
  drafts: {
    autosave: {
      interval: 100, 
    },
  },
}
...
  1. Enable localization in the payload config
...
localization: {
  defaultLocale: "en",
  locales: [{ code: "en", label: "English" }, { code: "it", label: "Italian" }],
},
...
  1. Add localized: true to some collection fields
  2. Try to create a new document

Adapters and Plugins

No response

mattiaz9 avatar Sep 23 '24 13:09 mattiaz9

Hey @mattiaz9 I did the same steps I cannot reproduce, using postgres with uuid as well. Can you share your collection config / confirm that it works on a minimal config?

r1tsuu avatar Sep 24 '24 02:09 r1tsuu

Hi @r1tsuu. It's funny, this morning I tried again and it didn't show the 404.

I noticed that the document is still created automatically. I can see 2 versions created immediately: Screenshot 2024-09-24 at 08 37 44

If I open the first version it gives me this error: TypeError: Cannot convert undefined or null to object

In the second version a can see it changes some fields from null to empty value: Screenshot 2024-09-24 at 08 37 57

I'm not sure why yesterday it showed me a 404 and today it doesn't, but still, creating the document during autosave, I believe could create some problems like this. It's probably best to disable creation when it is requested from an autosave.

mattiaz9 avatar Sep 24 '24 06:09 mattiaz9

I'm seeing this same issue on beta.123, but unrelated to localization. I was previously running on beta.117 without issue but I've refactored a lot while upgrading to the latest beta.

In my case, it seems like just having autosave turned on will result in an immediate redirection from /admin/collections//create to /admin/collections//

My configuration is complex in other ways, still working to narrow down what's causing it. For now, disabling autosave entirely seems to prevent the issue.

marpstar avatar Nov 04 '24 17:11 marpstar

This issue has been marked as stale due to lack of activity.

To keep this issue open, please indicate that it is still relevant in a comment below.

github-actions[bot] avatar Dec 13 '24 05:12 github-actions[bot]

This issue was automatically closed due to lack of activity.

github-actions[bot] avatar Dec 21 '24 05:12 github-actions[bot]

I am unable to reproduce this error. If you can repro this on the latest version (3.47.0 as of writing this comment) please add more steps to reproduce — a screen recording would also be super helpful.

JarrodMFlesch avatar Jul 14 '25 15:07 JarrodMFlesch

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

github-actions[bot] avatar Jul 22 '25 05:07 github-actions[bot]