[BUG] Multi Provider: hookContexts.get(context) fails, but works with context.context
Hi, I ran into an issue when using the Multi Provider. These two lines don’t work for me as-is (link):
const hookContext = this.hookContexts.get(context);
const hookHints = this.hookHints.get(context);
But when I change them to this, it works:
const hookContext = this.hookContexts.get(context.context);
const hookHints = this.hookHints.get(context.context);
Has anyone else experienced this?
I’m using FlagdProvider and the EnvVarProvider provider.
Thanks!
Slack thread: https://cloud-native.slack.com/archives/C0344AANLA1/p1762349668823959
Minimal reproduction: https://github.com/laszlorostas/openfeature-multi-test
I will add on to this my example repo using only the InMemoryProvider. I provided ESM and CJS versions to be extra sure it wasn't something crazy happening with that either.
https://github.com/mdkitzman/openfeature-multiprovider-esm-test
There does appear to be some issue with the context information lookup due to the fact that Map key lookup for objects is done by reference.
In my example it looks like after hook execution in the OpenFeature sdk, a copy of the context is made (and frozen) so when the evaluation phase is executed, and the MultiProvider attempts to do a lookup that context in the hook map, it cannot be found, even though the contents of the contexts are the same, they aren't the same reference.