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

feat: add Parse.Object.saveAllSettled to support more robust saving of multiple Parse Objects #1432

Closed
wants to merge 5 commits into from

Conversation

simonaberry
Copy link

@simonaberry simonaberry commented Nov 22, 2021

New Pull Request Checklist

Issue Description

Related issue: #494 #799 #1433 and this StackOverflow issue

Parse.Object.saveAll can create data consistency issues. Because saveAll (which uses the /batch endpoint) will reject if any of the save items in the list fails, you can end up with 19 saved objects and 1 unsaved object. If the cause of the failure was a network delay, then the saveAll will automatically retry, with all 20 objects again - which leads to duplicated objects on the server.

Approach

Parse.Object.saveAllSettled fixes this problem, by using the Promise.allSettled method and individual, staggered object. save() calls - which waits for the saving of all the objects in the list to resolve or reject, then only tries to resave any objects that didn't successfully save the first time.

TODOs before merging

  • Add tests
  • Add entry to changelog
  • ?support passing of context?

@parse-github-assistant
Copy link

parse-github-assistant bot commented Nov 22, 2021

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@simonaberry
Copy link
Author

I tried to do some test, but could not figure out how the xhr.open.mock.calls bit works ... bit out of my depth there

@simonaberry simonaberry changed the title SaveAllSettled feat: add Parse.Object.saveAllSettled to support more robust saving of lists of Parse Objects Nov 22, 2021
@simonaberry simonaberry changed the title feat: add Parse.Object.saveAllSettled to support more robust saving of lists of Parse Objects feat: add Parse.Object.saveAllSettled to support more robust saving of multiple Parse Objects Nov 22, 2021
@mtrezza
Copy link
Member

mtrezza commented Nov 22, 2021

Could you please create an issue or reference an existing issue for this PR.

@mtrezza
Copy link
Member

mtrezza commented Dec 5, 2021

Closing as the issue has been identified as merely a docs issue and transferred to docs repo as parse-community/docs#859.

@mtrezza mtrezza closed this Dec 5, 2021
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

Successfully merging this pull request may close these issues.

2 participants