Join our community: https://t.me/+DOylgFv1jyJlNzM0
Description
The backend generates requestId values via createRequestId() and uses runWithRequestContext() for log correlation in the event indexer. However, HTTP route handlers do not appear to propagate the requestId from the HTTP request into database queries or downstream service calls.
This means when debugging a production issue, you cannot trace a specific user request through logs from the HTTP layer to the DB query to the Soroban RPC call. You can see each layer's logs independently but cannot correlate them.
Expected Behavior
- Generate or extract a
requestId (from X-Request-ID header or generate one) at the middleware level for every incoming HTTP request
- Pass it through
runWithRequestContext() so all subsequent log statements in that request's lifecycle include the same requestId
- Include the
requestId in error responses so users can report it to support
Suggested Fix
Add a requestId middleware that runs before all routes:
app.use((req, res, next) => {
const requestId = req.headers['x-request-id'] ?? createRequestId();
runWithRequestContext(requestId, () => {
res.setHeader('X-Request-ID', requestId);
next();
});
});
Impact
Low-Medium. Not a bug but a significant observability gap that makes production incident investigation very slow.
Description
The backend generates
requestIdvalues viacreateRequestId()and usesrunWithRequestContext()for log correlation in the event indexer. However, HTTP route handlers do not appear to propagate therequestIdfrom the HTTP request into database queries or downstream service calls.This means when debugging a production issue, you cannot trace a specific user request through logs from the HTTP layer to the DB query to the Soroban RPC call. You can see each layer's logs independently but cannot correlate them.
Expected Behavior
requestId(fromX-Request-IDheader or generate one) at the middleware level for every incoming HTTP requestrunWithRequestContext()so all subsequent log statements in that request's lifecycle include the samerequestIdrequestIdin error responses so users can report it to supportSuggested Fix
Add a
requestIdmiddleware that runs before all routes:Impact
Low-Medium. Not a bug but a significant observability gap that makes production incident investigation very slow.