question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I have a question

See original GitHub issue

Hi, I’m so impressed by cls-rtracer so I researched about cls and cls-hooked.

I’m creating my module using cls-hooked to learn deeply.

I’ve following and trying this post: here

However, It’s a little bit different implemented code against your code. https://github.com/puzpuzpuz/cls-rtracer/blob/master/index.js#L61

And my code is :

const traceId = (opts: { test: number } | undefined): Middleware => {
  return async (ctx: Context, next: Function) => {
    // req and res are event emitters. We want to access CLS context inside of their event callbacks
    clsNamespace.bindEmitter(ctx.req);
    clsNamespace.bindEmitter(ctx.res);

    const traceID = uuidv4();

    clsNamespace.run(() => {
      clsNamespace.set('traceID', traceID);
      return next();
    });
  };
};

I’m wondering why you didn’t use clsNamespace.run() . I think I’m not enough to understand at all. Is it same working code?

best wishes.

Steve.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
puzpuzpuzcommented, Feb 3, 2020

@love8587 no problem at all. I’m glad to be able to help.

I’ll close this issue as the question seems to be answered. Feel free to reopen it or create another one.

1reaction
love8587commented, Feb 3, 2020

@puzpuzpuz many thanks. That’s very important and helpful to me. My code is starting to look very similar to your code. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

I Have Questions - Wikipedia
"I Have Questions" is a song recorded by Cuban-American singer and songwriter Camila Cabello. It was first featured as an intro on the...
Read more >
Camila Cabello – I Have Questions Lyrics - Genius
[Chorus 1] I have questions for you. Number one, tell me who you think you are. You got some nerve trying to tear...
Read more >
Children's Books | I Have a Question
The I Have a Question book series offers clear answers for all kids on life's most challenging topics.
Read more >
tense - "I had a question" or "I have a question"
It's true that a more oblique or indirect expression can sound more polite. In approximate order of increasing politeness/deference, ...
Read more >
Which one is correct? 'I have a question for/to you' - Quora
The correct word is neither to or from, but “of.” You might say, “I would like to ask a few questions of Mr....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found