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

Re-raise errors from Async::Tasks in AsyncDataloader #4736

Merged
merged 1 commit into from
Dec 20, 2023

Conversation

rmosolgo
Copy link
Owner

Hopefully fixes #4735

@rmosolgo rmosolgo added this to the 2.2.1 milestone Dec 19, 2023
@rmosolgo rmosolgo merged commit 00f2323 into master Dec 20, 2023
12 checks passed
@rmosolgo rmosolgo deleted the async-dataloader-error-handling branch December 20, 2023 13:34
@swrobel
Copy link
Contributor

swrobel commented Dec 20, 2023

Apologies for not getting to test this promptly! It does indeed fix my issue with the exceptions being swallowed, but I still get a very verbose warning printed for every spec where an exception is raised, ex:

20.25s     warn: Async::Task [oid=0x7eb94] [ec=0x7eba8] [pid=15504] [2023-12-20 08:59:28 -0500]
               | Task may have ended with unhandled exception.
               |   Pundit::NotAuthorizedError: not allowed to import? this Order
               |   → vendor/bundle/ruby/3.2.0/gems/pundit-2.3.1/lib/pundit.rb:86 in `authorize'
               |     vendor/bundle/ruby/3.2.0/gems/pundit-2.3.1/lib/pundit/authorization.rb:67 in `authorize'
               |     app/graphql/mutations/orders/import.rb:26 in `resolve'
               |     vendor/bundle/ruby/3.2.0/gems/appmap-0.103.0/lib/appmap/hook/method/ruby3.rb:44 in `bind_call'
               |     vendor/bundle/ruby/3.2.0/gems/appmap-0.103.0/lib/appmap/hook/method/ruby3.rb:44 in `do_call'
               |     vendor/bundle/ruby/3.2.0/gems/appmap-0.103.0/lib/appmap/hook/method/ruby3.rb:53 in `trace_call'
               |     vendor/bundle/ruby/3.2.0/gems/appmap-0.103.0/lib/appmap/hook/method/ruby3.rb:20 in `call'
               |     vendor/bundle/ruby/3.2.0/gems/appmap-0.103.0/lib/appmap/hook/method/ruby3.rb:70 in `block in hook_method_def'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/resolver.rb:107 in `public_send'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/resolver.rb:107 in `block (3 levels) in resolve_with_support'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:770 in `minimal_after_lazy'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/query.rb:372 in `after_lazy'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/resolver.rb:94 in `block (2 levels) in resolve_with_support'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:770 in `minimal_after_lazy'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/query.rb:372 in `after_lazy'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/resolver.rb:85 in `block in resolve_with_support'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:770 in `minimal_after_lazy'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/query.rb:372 in `after_lazy'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/resolver.rb:73 in `resolve_with_support'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/has_single_input_argument.rb:36 in `resolve_with_support'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/relay_classic_mutation.rb:45 in `resolve_with_support'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/field.rb:698 in `public_send'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/field.rb:698 in `block (2 levels) in resolve'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/field.rb:832 in `with_extensions'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/field.rb:669 in `block in resolve'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:770 in `minimal_after_lazy'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/query.rb:372 in `after_lazy'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/field.rb:667 in `resolve'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:358 in `block (2 levels) in evaluate_selection_with_resolved_keyword_args'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/tracing/trace.rb:52 in `execute_field'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:357 in `block in evaluate_selection_with_resolved_keyword_args'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:709 in `call_method_on_directives'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:354 in `evaluate_selection_with_resolved_keyword_args'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:331 in `block in evaluate_selection_with_args'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:830 in `after_lazy'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:279 in `evaluate_selection_with_args'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/runtime.rb:273 in `block in evaluate_selection'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/execution/interpreter/arguments_cache.rb:51 in `block in dataload_for'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/schema/member/has_arguments.rb:300 in `block (3 levels) in coerce_arguments'
               |     vendor/bundle/ruby/3.2.0/gems/graphql-2.2.1/lib/graphql/dataloader/async_dataloader.rb:65 in `block in spawn_job_task'
               |     vendor/bundle/ruby/3.2.0/gems/async-2.6.5/lib/async/task.rb:160 in `block in run'
               |     vendor/bundle/ruby/3.2.0/gems/async-2.6.5/lib/async/task.rb:330 in `block in schedule'

Edit: I found out that adding an initializer that calls Console.logger.disable(Async::Task) silences these.

@rmosolgo
Copy link
Owner Author

👍 Thanks for sharing what you found, I went looking at the async repo, too, and found that the same solution is recommended there: socketry/async#279 (comment)

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.

Cannot run spec suite when using GraphQL::Dataloader::AsyncDataloader
2 participants