Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text is getting swapped and mixed up between recently edited pages on Save / Publish #4891

Closed
jeremyzilar opened this issue Jan 29, 2021 · 2 comments · Fixed by #5804
Closed
Labels
type: bug code to address defects in shipped code

Comments

@jeremyzilar
Copy link
Contributor

jeremyzilar commented Jan 29, 2021

Describe the bug
We are seeing an issue where our editors are making/editing pages through NetlifyCMS and when saving, the data is getting mixed up with data from other posts/pages and then published...

Here is what happens, roughly:

  • An editor sets out to create five event pages — Event A, Event B, Event C, Event D, Event E.
  • Each one is in a state of draft in NetlifyCMS till all of the information is gathered, at which point that event is published.

At any point in the process of producing these events, from one event could leak into the data from another event. It doesn't matter if the event is published or still in draft. Though it does seem to happen with the event pages that our editor has recently edited.

Example: If you look at the history of edits to this page, you'll see that at some point, most (not all) of the content on the page gets swapped out for the content of another event page (here is the diff)

image

Further investigation

The area of the NetlifyCMS that seems to be affected most is where we are pulling data from another content type called "People". Recently, we have been noticing that it is taking a really long time to pull up the list of "people" to choose from in the CMS. Might the cause for issue be in this request and query? Is the local memory getting exceeded or something along those lines?
image

Also, when our editors (and myself) see this pop-up, we have no idea what it means. When asked, they say they press OK and just check the page for possible errors.

image

About our site + technology

Any thoughts or ideas on how to fix this would be amazing ❤️🌈🌲🌵

@jeremyzilar jeremyzilar added the type: bug code to address defects in shipped code label Jan 29, 2021
@jeremyzilar
Copy link
Contributor Author

jeremyzilar commented Feb 4, 2021

This happened again today, and our editor got this error:

undefined is not an object (evaluating 'e.get')

image

@namvu9
Copy link

namvu9 commented Mar 9, 2021

This has been happening to us too and at times the CMS is completely unusable for us with content constantly being overwritten by changes to completely unrelated posts. I have a hunch that it may have something to do with this call to retrieveLocalBackup inside the componentDidMount method of the Editor widget:

https://github.com/netlify/netlify-cms/blob/5bcbe7b0edece438e94cae92c4fbf2e718f2a076/packages/netlify-cms-core/src/components/Editor/Editor.js#L97

I managed to reproduce the same effect by adding a delay inside retrieveLocalBackup to simulate the latency of the call to async backendGetLocalDraftBackup():

export function retrieveLocalBackup(collection: Collection, slug: string) {
  return async (dispatch: ThunkDispatch<State, {}, AnyAction>, getState: () => State) => {
    const state = getState();
    const backend = currentBackend(state.config);
    setTimeout(async () => {
      const { entry } = await backend.getLocalDraftBackup(collection, slug);

      console.log('RETRIEVE LOCAL BACKUP', slug, JSON.stringify(entry, null, 2));

      if (entry) {
        // load assets from backup
        const mediaFiles = entry.mediaFiles || [];
        const assetProxies: AssetProxy[] = await Promise.all(
          mediaFiles.map((file) => {
            if (file.file || file.url) {
              return createAssetProxy({
                path: file.path,
                file: file.file,
                url: file.url,
                field: file.field,
              });
            } else {
              return getAsset({
                collection,
                entry: fromJS(entry),
                path: file.path,
                field: file.field,
              })(dispatch, getState);
            }
          }),
        );
        dispatch(addAssets(assetProxies));

        return dispatch(localBackupRetrieved(entry));
      }
    }, 3000);
  };
}

In this case, upon loading post A, a call to retrieveLocalBackup is made inside componentDidMount. Before it returns, I navigate to post B. At some point, the original call to retrieveLocalBackup completes and sets the editor's fields to be that of post A.

With that said, I'm not entirely sure that's the root cause of the bug we see in production, given my lack of knowledge of the code base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants