Hey! I'm not sure if I'm misinterpreting the documentation or whether I've stumbled onto a bug.
I'm trying to use the CacheService in an Auth Provider to store state and PKCE values across OAuth redirects. I'm aware it's probably not the right thing to do! I ran into an AilixResolutionError that meant the Provider I created was crashing when trying to resolve the cacheService, which several parts of the docs at least alude to being accessible:
https://docs.medusajs.com/resources/architectural-modules/cache/create#4-use-module - mentioning the cacheService key specifically
https://docs.medusajs.com/resources/medusa-container-resources#module-container-resources - mentioning Modules' services using camelcase'd names
To that end, I added a key, cacheService into the first argument of my Provider's constructor, like so:
constructor(
{ logger, cacheService }: { logger: Logger, cacheService: ICacheService },
options: Options
) {
super(...arguments);
this.cacheService_ = cacheService;
...
}
The types are all happy with what I've done, but when accessing the http://[storefront_url]/auth/user/oauth-generic endpoint I was getting an error which didn't make sense:
Unable to retrieve the auth provider with id: oauth-generic
Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.
I double and triple verified that my Provider oauth-generic was available, but the error persisted. After some more investigation, I found a catch block that was swallowing the real error. After patching @medusajs/auth/dist/services/auth-provider.js:31 to throw the error in the CLI, I got the real error:
AwilixResolutionError: Could not resolve 'cacheService'.
Resolution path: au_oauth-generic -> cacheService
[ 1/2 ]