AsyncDataloader: Rescue all errors before they reach Async#5672
Open
rmosolgo wants to merge 5 commits into
Open
AsyncDataloader: Rescue all errors before they reach Async#5672rmosolgo wants to merge 5 commits into
rmosolgo wants to merge 5 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, AsyncDataloader allowed some errors to propagate all the way to Async, causing warnings in the console about unhandled errors.
The problem was my use of
ensure ...to handle errors within tasks. That code was run, and it handled the raised error (as$!), but then the error keep propagating upwards. So I switched that forrescue ... else ... ensure ..., with some code running in case of an error, other code running when there is no error, and still more code running in both cases.Further confusing the debugging, Dataloader's own error handling grabs errors and stores them as results on
Sourceinstances, raising them again later when the result is provided to the caller. This meant that Job tasks would raise errors (from dataloader calls) whose backtraces pointed toSource#fetch. It made it a little hard to realize what was going on -- but I think it's still the right behavior, since that's where the error really came from.Now, all errors are (should be?!) handled by GraphQL-Ruby before they propagate to the task's
do ... endblock. A raised error causes the whole query to end; if other ongoing tasks have errors, they disappear silently.TODO: