-
Notifications
You must be signed in to change notification settings - Fork 9
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
Redis KeyvAdapter DataLoader throws TypeError because the result is undefined #256
Comments
Hope this is helpful, let me know if this solves your issue. Can we document this better to make it more discoverable? |
@trevor-scheer Thanks for the quick reply! I'm not sure #211 this solves the issue, rather it's the cause of the issue I'm reporting 😄 I agree that an error should not be thrown if the connection is lost, and that using the The issue occurs when an array of keys are provided to DataLoader, and DataLoader then expects that an array with the same amount of elements are returned by the batch loading function, but since the So for example, if keys The DataLoader documentation mentions these constraints on the batch loading function:
So, an alternative to the initial suggested fix, would be to instead fix it in |
Thanks for the additional details! I'll have a closer look at this near the end of the week. |
@HishamAli81 thanks for that. I was able to reproduce trivially. I've got a PR open to resolve (as well an open issue on the Keyv repo - there's a bug in either the typings or the runtime). |
@trevor-scheer Thanks for the quick turnaround! |
When using the Redis Keyv and if the Redis client is unable to connect to the Redis cluster, the
keyv.get()
function will returnedundefined
.This in turn would cause the DataLoader used by the KeyvAdapter to throw the following error since returning
undefined
violates the DataLoader contract:Would suggest changing the following KeyvAdapter code to better handle this error scenario:
For example, to something like this:
I haven't tested this with other Keyv implementations so this issue exist with other caches besides Redis. I've also only noticed this issue occurring when Redis can't connect to the cluster, but could possible occur for other type of Redis errors as well.
The text was updated successfully, but these errors were encountered: