Cannot set properties of undefined (setting 'namespace') 3.7.0 error
daanootje opened this issue · 1 comments
daanootje commented
Could be a duplicate of #654. After recently changing to 3.7.0 we are encountering the following error:
2024-06-06T10:52:44.066Z | INIT_START Runtime Version: nodejs:18.v29 Runtime Version
2024-06-06T10:52:44.895Z | undefined ERROR _X_AMZN_TRACE_ID is missing required information
2024-06-06T10:52:44.896Z | undefined ERROR Empty or non-string trace ID provided
2024-06-06T10:52:45.750Z | START RequestId: 60bee989-dc24-514d-a1cc-b7524b09db45
2024-06-06T10:52:46.105Z | ERROR Invoke Error
{
"errorType": "RequestError",
"errorMessage": "Cannot set properties of undefined (setting 'namespace')",
"code": "ERR_GOT_REQUEST_ERROR",
"name": "RequestError",
"stack": [
"RequestError: Cannot set properties of undefined (setting 'namespace')",
" at captureOutgoingHTTPs (/var/task/node_modules/aws-xray-sdk-core/dist/lib/patchers/http_p.js:108:30)",
" at Object.captureHTTPsRequest [as request] (/var/task/node_modules/aws-xray-sdk-core/dist/lib/patchers/http_p.js:175:16)",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
]
}
2024-06-06T10:52:46.109Z | END RequestId: 60bee989-dc24-514d-a1cc-b7524b09db45
2024-06-06T10:52:46.109Z | REPORT RequestId: 60bee989-dc24-514d-a1cc-b7524b09db45 Duration: 359.46 ms Billed Duration: 360 ms Memory Size: 1024 MB Max Memory Used: 137 MB Init Duration: 1683.30 ms
XRAY TraceId: 1-666194fb-4d3d1850fcf803f9e905fdf7 SegmentId: 161caf1c19d1cbf2 Sampled: true
The code tries to bind the xray trace id to an outgoing http request.
import * as awsXRay from 'aws-xray-sdk-core'
import https from 'https'
const enableTracing = true
export function makeXrayHttps({ enableTracing }: { enableTracing: boolean }) {
return enableTracing ? awsXRay.captureHTTPs(https, true) : https // <-- Most likely failing here
}
const xrayHttps = makeXrayHttps({ enableTracing })