Skip to content

fix(core): handle nested context correctly with UseCls decorator - #119

Merged
Papooch merged 1 commit into
Papooch:mainfrom
alexandre-abrioux:fix-usecls
Feb 3, 2024
Merged

Papooch merged 1 commit into
Papooch:mainfrom
alexandre-abrioux:fix-usecls

Conversation

@alexandre-abrioux

@alexandre-abrioux alexandre-abrioux commented Feb 2, 2024 •

Copy link
Copy Markdown
Contributor

Issue

Methods decorated with @UseCls() (without runOptions) are not called when running inside a parent context.

Fix

This PR prepends the default options to the options passed down to the cls.run(options, callback) function. This way, options.ifNested is always defined (default to inherit), and the callback is always triggered in the switch (options.ifNested) ... case block.

Since @UseCls() calls run with an empty options object: cls.run({}, callback) ; it fixes the issue 👍

Comment thread packages/core/src/lib/cls.service.ts
Comment thread packages/core/src/lib/cls.service.ts
@Papooch

Papooch commented Feb 2, 2024

Copy link
Copy Markdown
Owner

Thank you for finding and fixing all these issues 💪 I'll get to revieving them as soon as I get to a computer!

@Papooch Papooch changed the title fix(use-cls-decorator): handle nested context fix(core): handle nested context correctly with UseCls decorator Feb 3, 2024

@Papooch Papooch left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💪

@Papooch
Papooch merged commit df90f30 into Papooch:main Feb 3, 2024
@alexandre-abrioux
alexandre-abrioux deleted the fix-usecls branch February 3, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants