You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading from version 3.6.0 to 4.3.0, I started receiving the following error:
TypeError: Invalid value used as weak map key
at WeakMap.set (<anonymous>)
at ContextClsStoreMap.set (node_modules/nestjs-cls/dist/src/lib/cls-initializers/utils/context-cls-store-map.js:26:25)
at ClsGuard.canActivate (node_modules/nestjs-cls/dist/src/lib/cls-initializers/cls.guard.js:34:56)
at GuardsConsumer.tryActivate (node_modules/@nestjs/core/guards/guards-consumer.js:15:34)
....
I'm using "ClsGuard" in a WebSsocket context, and in this case, my WebSocket data is a string and not an object.
The ContextClsStoreMap.getContextByType function, with context.switchToWs().getData(), is leading to this error.
For now, I'm reverting to 3.6.0. And if I get more time, I'll check if I can fix it and do a pull request.
The text was updated successfully, but these errors were encountered:
Thanks for the bug report and also pin-pointing the exact issue!
The context map is there mainly as an escape hatch for some non-trivial GraphQL use-cases (see #88).
In the case of websockets, I think it's safe to use the entire WsArgumentsHost as the context map key, so context.switchToWs() should be enough for a fix (seeing as there is no other object that can be used instead of Data).
If you want, create a PR with that change, otherwise I'll get to it when I get some free time.
Hello,
After upgrading from version 3.6.0 to 4.3.0, I started receiving the following error:
I'm using "ClsGuard" in a WebSsocket context, and in this case, my WebSocket data is a string and not an object.
The ContextClsStoreMap.getContextByType function, with context.switchToWs().getData(), is leading to this error.
For now, I'm reverting to 3.6.0. And if I get more time, I'll check if I can fix it and do a pull request.
The text was updated successfully, but these errors were encountered: