Skip to content

AsyncDataloader: Rescue all errors before they reach Async#5672

Open
rmosolgo wants to merge 5 commits into
masterfrom
async-dataloader-error-handling
Open

AsyncDataloader: Rescue all errors before they reach Async#5672
rmosolgo wants to merge 5 commits into
masterfrom
async-dataloader-error-handling

Conversation

@rmosolgo

@rmosolgo rmosolgo commented Jul 15, 2026

Copy link
Copy Markdown
Owner

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 for rescue ... 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 Source instances, 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 to Source#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 ... end block. A raised error causes the whole query to end; if other ongoing tasks have errors, they disappear silently.

TODO:

  • Add a test for this, asserting that nothing is warned when concurrent tasks raise errors

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.

1 participant