Open dreamorosi opened 2 months ago
Just landed here as I was wondering why I'm seeing that error.
My use case isn't necessary valid. I was just testing out various (premature 😅 ) optimizations where I call one async function (that essentially initializes a Promise that starts making HTTP calls) before the handler function and then later in the handler I actually await
the value of that Promise. I'm not yet even sure if I that makes any real difference, but generally speaking I can see think of various reasons of doing similar things.
Is there maybe a workaround to disable the logging of that error? This error message clutters our logs 😅.
The log comes from the X-Ray SDK for Node.js as we can see from the stack trace above.
I haven't tested it, but I think setting the AWS_XRAY_CONTEXT_MISSING
env var to IGNORE_ERROR
as specified here might do the trick.
Thx for the answer, I'll try that.
I can confirm that with the environment variable AWS_XRAY_CONTEXT_MISSING
set to IGNORE_ERROR
the error is no longer logged 👍🏼. Thank you for the hint @dreamorosi.
Use case
Currently when using the Parameters and Tracer utility together, and with top-level
await
(like shown below) used in a certain order an error is logged (but not thrown) informing that the X-Ray SDK is unable to find a trace root (expected).This is the log emitted by the AWS X-Ray SDK, which attempts to trace the request made
This is expected in the sense that trace data is available only within the
handler
scope and made available by the AWS Lambda service only when invoking your function.This is not a runtime error (which is also why this is a feature request and not a bug) but nevertheless it's a nuisance and we should try to find a way to handle this case without making the AWS X-Ray SDK log the error.
Note that swapping the order of the Tracer instantiation and the Parameters call, like below, fixes the issue:
Solution/User Experience
The experience for customers should stay as-is and the change should be backwards compatible.
Alternative solutions
No response
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.