feat(gatsby-core-utils): add fetch mutex for PQR #33161
Merged
+541
−119
Conversation
vladar
reviewed
Sep 14, 2021
| if (entry.status === `complete`) { | ||
| cb(entry.result) | ||
| } else { | ||
| setTimeout(() => { | ||
| pollUntilComplete(cache, url, buildId, cb) | ||
| // Magic number | ||
| }, 500) | ||
| } |
What happens if a worker starts polling but then the "main" worker fails (i.e. requestRemoteNode throws)? I don't see how it can exist from this function in this case. Can we have a test case for it as it is a typical scenario?
We keep on hanging
Depends on how folks use it. If it happens in custom resolver - the corresponding field can just return null (graphql allows partial errors for nullable fields)
vladar
reviewed
Sep 14, 2021
Thank you
vladar
approved these changes
Sep 14, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
When multiple workers fetch the same file we end up with multiple requests to that file. We write to a seperate tmp file but the end result writes (fs.move) to the same file.
This can lead to corrupt files if other parts of the application are resolving it. This PR creates some hacky mutex implementation to make it only write once. It's still possible to write multiple tmp files.
As an adittion I took the inFlight cache from #30391 and implemented it as well to do less polling.
The text was updated successfully, but these errors were encountered: