Skip to content

CLS context is not active #133

Closed Answered by Papooch
cssArchitect asked this question in Q&A
Apr 3, 2024 · 1 comments · 10 replies
Discussion options

You must be logged in to vote

I was able to reporoduce it on latest version of Nest. When I use the ClsGuard from nestjs-cls, it does not suffer from the same issue (due to not awaiting anything before entering).

That said, the .enterWith method is still experimental, so bugs like these are not that surprising. Therefore I am afraid that I can't fix this in the library.

As you also discovered, the fix is to run it synchronously, so I would propose changing the logic in the guard so that any awaited calls are executed only after cls.enterWith is called. The function can still be marked async, because Node runs all code within an async function synchronously, until the first await.

If you want to be sure, create the pro…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@Papooch
Comment options

@cssArchitect
Comment options

@cssArchitect
Comment options

@Papooch
Comment options

Answer selected by cssArchitect
@cssArchitect
Comment options

@cssArchitect
Comment options

@Papooch
Comment options

@Papooch
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants