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

When updating most of the document gets removed #18

Open
StorytellerCZ opened this issue Sep 29, 2024 · 1 comment
Open

When updating most of the document gets removed #18

StorytellerCZ opened this issue Sep 29, 2024 · 1 comment

Comments

@StorytellerCZ
Copy link

Run into this strange error just recently. I'm subscribed to profiles collection (from socialize:profiles - have it locally for Meteor 3) through the app. In my text editor I have triggered a function to change a field on my profile like this:

Meteor.methods({
'profile.readerSettings.darkMode': async (setTo: boolean) => {
    check(setTo, Boolean)
    const userId = Meteor.userId()
    if (!userId) throw notAuthorized
    return await ProfilesCollection.updateAsync(
      { _id: userId },
      { $set: { 'readerSettings.darkMode': setTo } },
    )
  },
})

Strangely though the profile document gets replaced with the change and two extra fields. Which results in other important fields missing. Calling other methods around the editor that also change the readerSettings then adds other fields back in.

Removing and adding the package seemed to fix the issue (which is why I was able to pin it to this package).

Then I found that if the offline package is last in the packages file then the problem does not occur. So maybe the package needs to be loaded after all the packages with collections have been loaded to prevent this issue?

@jamauro
Copy link
Owner

jamauro commented Oct 4, 2024

Interesting. I'll try to reproduce but if you could help with a minimal repro without socialize that would be appreciated.

Then I found that if the offline package is last in the packages file then the problem does not occur. So maybe the package needs to be loaded after all the packages with collections have been loaded to prevent this issue?

Sounds like a workaround for now until we have a better diagnosis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants