Failed to get the current sub/segment from the context
See original GitHub issueI have a NodeJs service (using express) that we are now trying to monitor with Xray. For some reason, every time a new request is issued, I get the following error:
[ERROR] Error: Failed to get the current sub/segment from the context.
at Object.contextMissingLogError [as contextMissing] (/Users/ronagar/src/node_modules/aws-xray-sdk-core/lib/context_utils.js:26:19)
at Object.getSegment (/Users/ronagar/src/node_modules/aws-xray-sdk-core/lib/context_utils.js:102:45)
at tryGetCurrentSegment (/Users/ronagar/src/node_modules/aws-xray-sdk-core/lib/patchers/promise_p.js:63:25)
at Promise.then (/Users/ronagar/src/node_modules/aws-xray-sdk-core/lib/patchers/promise_p.js:20:12)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
There’s no additional stack, so there’s really no way to determine where this issue comes from.
After hours of debugging I’m still clueless as to where the culprit is.
Every time I change something, the error pops up some place else.
As you can see the error happens in the promise patching. when disabling capturePromise the error goes away, but we need this as we have many promises & external calls running during the request.
One thing that I keep noticing is that if I see the error happens when calling a specific function. I change this function code to async/await and suddenly this goes away. but I do have other functions that do have regular promises and they don’t crash.
Is there any way to identify what is the culprit? how to resolve this?
Stack that I think relevant: NodeJs 12.17.0 aws-sdk 2.294.0 aws-xray-sdk 3.3.1 axios 0.21.2 bluebird 3.7.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Related StackOverflow Question
@atlanteh if you don’t want this error to come up while debugging please set the
AWS_XRAY_CONTEXT_MISSINGenvironment variable toLOG_ERRORorIGNORE_ERROR. For more info, see the readme.This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in next 7 days. Thank you for your contributions.