-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix: improve handling of promises in defaultTypeResolver #3494
Conversation
This means that a mixture of sync/async calls becomes sync unnecessarily, as we return sync value…. Maybe catch handlers should be added to the promises so they reject silently? Is that possible? |
I had considered that, but silently swallowing errors seems like a bad idea. I think it makes sense for execution to become async if any async functions are called. This should be a pretty rare case, but if these errors were swallowed silently it could become very tricky to debug. |
Maybe there should be a side channel for logging these errors then so as they are not silent? In fact, this can be addressed currently in user space, as long as isTypeOf functions catch their errors and log them… this differs from field or type resolvers which must never reject, but it’s not quite a problem for an isTypeOf resolver fail if another succeeds. not 100% sure what the right answer is |
A side channel might be useful as well in context of #2974 to report the first error to client and potentially log all errors |
But as there currently is no side channel, I think I would approve these changes, and then refactor later |
The latest changes of this PR are available on NPM as Also you can depend on latest version built from this PR: |
✅ Deploy Preview for compassionate-pike-271cb3 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
kinda forgot about this PR, but I think this change would still be good to get in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 2 different questions:
- Should there ever be unhandled promise rejections?
- Must all errors be reported?
There probably should never be unhandled promise rejections, but we do not necessarily need to report all errors.
d8237f7
to
68a04f2
Compare
Forgot about this PR, but wanted to check in and see if this can get merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the right change to me in terms of error-resilience - there is an unwanted commit in the history here though
Good catch! I removed the extra commit and rebased the pr |
@JoviDeCroock I don't feel strongly about which release this makes it into, for me its not urgent, it just seems like it would be good to land eventually |
Currently it is possible to have unhandled promise rejections that arise from a mix of sync and async isTypeOf checks.
This should fix that issue.