fix(gatsby-source-drupal): Ensure node updates are handled sequentially to avoid race conditions when saving nodes #36026
+879
−115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#35323 changed how we persisted references — because of that some functions had to become async but we didn't properly update all code to await. We also ran node updates in parallel instead of sequentially. This meant that sites with many references could experience a race condition where some changes aren't applied correctly as we update the nodes multiple times during the incremental source for each reference change and an older version might overwrite a newer as the updates were happening in parallel instead of sequentially.
This PR properly awaits everything + changes our mocked cache for tests to also be async to avoid any similar regressions happening in the future.