Closed rohitkhatri closed 3 years ago
Hi @rohitkhatri
Is there a reason why you do
app.use((req, res, next) => {
console.log('app.js->reqId:', req.headers['reqid']); // request-100001
if (req.headers['reqid']) {
RequestTracer.runWithId(next, req.headers['reqid']);
} else {
RequestTracer.expressMiddleware()(req, res, next);
}
});
instead of
app.use(RequestTracer.expressMiddleware({
useHeader: true,
headerName: 'reqid'
}));
?
Ohh yes, I didn't know about this configuration for the middleware, It's working for me, thanks.
I'm trying to access request id in a form-data request with file upload, I'm using runWithId if the request id is passed in headers otherwise expressMiddleware, but It says undefined. Please find the code below:
Here's a repl to run it:
https://replit.com/@rohitkhatri/cls-rtracer-code#index.js
It says undefined most of the times when id is passed, but works sometimes, but If the request id is not passed, It always works.
Can anyone please help me here?