puzpuzpuz / cls-rtracer

Request Tracer - CLS-based request id generation for Express, Fastify, Koa and Hapi, batteries included
MIT License
311 stars 24 forks source link

Expected requestId object is not returned with runWithId method #71

Closed rocktheshan closed 11 months ago

rocktheshan commented 11 months ago

In a setup where requestIdFactory is configured to return a map of particular Ids, when we use runWithId without the optional Id parameter, it should use that same requestIdFactory to assign a new map of the required Ids but with the current implementation, it is assigning a uuid id string.

puzpuzpuz commented 11 months ago

runWithId() is a separate utility function which is not related with the middleware/plugin you're using. That's because you may use multiple cls-rtracer middlewares/plugins in your application and it's not straightforward which one of them should be used to configure runWithId()'s default behavior.

To fix your code you should provide the id when calling runWithId().