Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during using the @MurLock decorator inside a service. #18

Closed
OsoianMarcel opened this issue Nov 4, 2023 · 7 comments
Closed

Error during using the @MurLock decorator inside a service. #18

OsoianMarcel opened this issue Nov 4, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@OsoianMarcel
Copy link
Collaborator

murlock version: 2.0.0
package manager: yarn v1.22.19
environment: docker image node:20-alpine
node version: v20.9.0
NestJS core & common version: ^10.0.0

Usage inside a service (not controller):

@MurLock(15e3, 'requestDto.itinerary_id')
  public async check(
    // requestDto contains a string property "itinerary_id"
    requestDto: RequestDto, 
  ): Promise<ResponseDto> {
  // ...
}

Error during calling the service method (with MurLock decorator):

[15:24:20.690] ERROR (63): Failed to acquire lock for key CheckService:check:5f92cbf10cf217478ba93561: Cannot set the key "clientId". No CLS context available, please make sure that a ClsMiddleware/Guard/Interceptor has set up the context, or wrap any calls that depend on CLS with "ClsService#run"
    req: {},
    context: "HttpExceptionFilter"
    err: {
      "type": "MurLockException",
      "message": "Failed to acquire lock for key CheckService:check:5f92cbf10cf217478ba93561: Cannot set the key \"clientId\". No CLS context available, please make sure that a ClsMiddleware/Guard/Interceptor has set up the context, or wrap any calls that depend on CLS with \"ClsService#run\"",
      "stack":
          MurLockException: Failed to acquire lock for key CheckService:check:5f92cbf10cf217478ba93561: Cannot set the key "clientId". No CLS context available, please make sure that a ClsMiddleware/Guard/Interceptor has set up the context, or wrap any calls that depend on CLS with "ClsService#run"
              at /home/node/app/node_modules/murlock/lib/decorators/murlock.decorator.ts:82:11
              at Generator.throw (<anonymous>)
              at rejected (/home/node/app/node_modules/murlock/dist/decorators/murlock.decorator.js:6:65)
              at processTicksAndRejections (node:internal/process/task_queues:95:5)
      "name": "MurLockException"
    }
@felanios
Copy link
Owner

felanios commented Nov 4, 2023

@OsoianMarcel Thanks for your support, I found the issue, bugfix is ​​on the way. Since I use Nestjs-cls for tracing in my services, there are a few things I missed.

@felanios felanios added the bug Something isn't working label Nov 4, 2023
@felanios
Copy link
Owner

felanios commented Nov 4, 2023

@OsoianMarcel https://www.npmjs.com/package/murlock/v/2.0.1 Fixed with this version, fyi.

@felanios felanios closed this as completed Nov 4, 2023
@OsoianMarcel
Copy link
Collaborator Author

OsoianMarcel commented Jan 30, 2024

@felanios
Can we remove the dependency "ClsModule"?
I'm receiving the same problem again on another project.
It seems like the "ClsModule" is only used for keeping the client ID.
Can we keep the ID inside the service itself on a private property or another place inside the "murlock" module?
This way, we'll remove an unnecessary dependency, and forget about this bug forever.
Thank you.

@felanios
Copy link
Owner

Hi @OsoianMarcel, I'm totally agree with that, I received feedback from different users regarding the same problem. I will solve this problem within this week.

@felanios felanios reopened this Jan 30, 2024
@felanios felanios self-assigned this Jan 30, 2024
@OsoianMarcel
Copy link
Collaborator Author

I created a PR #31, hope it helps to resolve the problem. Thx.

@felanios
Copy link
Owner

@OsoianMarcel I merged the pr, thank you for your contribution.Because of the semantic-release, package bumped to v3.0.1, fyi.
https://www.npmjs.com/package/murlock/v/3.0.1,

@OsoianMarcel
Copy link
Collaborator Author

@felanios thanks, it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants