Closed piotrjak closed 1 year ago
tl;dr this was the error
TypeError: parent.addNewSubsegmentWithoutSampling is not a function
at captureOutgoingHTTPs (/var/task/node_modules/@lifeworks/http-client-with-tracing/node_modules/aws-xray-sdk-core/dist/lib/patchers/http_p.js:103:33)
I saw that we were using aws-xray-sdk-core
in both http-client-with-tracing
and aws-sdk-helpers
they were both using different versions of this package -> 3.4.1 and 3.3.7
3.3.7 was at node_modules/aws-xray-sdk-core
3.4.1 was at node_modules/@lifeworks/http-client-with-tracing/node_modules/aws-xray-sdk-core
http-client-with-tracing
loaded aws-xray-sdk-core
first (as it was required earlier) and then aws-sdk-helpers
loaded.
but it was aws-sdk-helpers
that first sent a request (which was intercepted by aws-xray-sdk-core
). captureOutgoingHTTPs
from http-client-with-tracing
so it looks like it used the cached module (?)
it sent the request (SecretsManager.getSecretValue), but then http-client-with-tracing
sent an HTTP request. aws-xray-sdk-core
got an Xray segment from CLS ("node's local storage" -> like a global object that lives between requests) that is later used. but looks like this segment came from this other version of aws-xray-sdk-core
(on the screenshot parent is the object from getSegment)
and then the method from this shared object was used to call a method on it from library 3.4.1 that was unavailable
I found that this Segment is set in node_modules/aws-xray-sdk-core/dist/lib/env/aws_lambda.js:34
so it's the aws-xray-sdk-core
from aws-sdk-helpers
- that's called by init (node_modules/aws-xray-sdk-core/dist/lib/aws-xray.js:303
), but somehow it later calls captureOutgoingHTTPs
from aws-xray-sdk-core
from http-client-with-tracing
this init file (4th screenshot) was run in the process of require (IIFE function) when the module was trying to be loaded. so I assume that even though the module was cached, this module still invoked this IIFE function which set the segment...)
TL;DR anyway, THE FIX was to update our helper packages so it uses only one version of aws-xray-sdk-core so the packages sits directly in node_modules/aws-xray-sdk-core .
Thanks @piotrjak for the writeup, sorry for not responding earlier. I believe this is a dupe of #544, and since you've resolved it I'll close this issue.
Overview
AWSXRay.captureHTTPsGlobal(require('https'));
in the Debug Console
this method doesn't exist
Why does it say that it's using sdk-version 3.3.7 though? may it be a module caching issue?
Stack