-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
captureHTTPsGlobal now results in TypeError: Cannot redefine property: request
#487
Comments
I think reverting to Edit: yes, can confirm, downgrading to 3.2.0 fixes this. |
Hi @mrowles, Thanks for raising this. Definitely seems like a problem because we added TypeScript support, which changed the way we bundle our final package in This way we can see if the same fix would apply. |
I am seeing the same issue with CDK 2.15.0 (which uses esbuild), when the bundling output format is set to Lambda code: import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
import { captureAWSv3Client, captureHTTPsGlobal } from 'aws-xray-sdk';
import * as https from 'https';
const dynamoDbClient = new DynamoDBClient({ });
const dynamoDb = DynamoDBDocumentClient.from(dynamoDbClient);
captureAWSv3Client(dynamoDbClient);
captureHTTPsGlobal(https); // <-- fails here at runtime CDK resource: const apiHandlerFn = new njs.NodejsFunction(this, 'AccountDomainApiHandler', {
timeout: Duration.seconds(10),
runtime: lambda.Runtime.NODEJS_14_X,
entry: path.join(__dirname, '../src/account-domain-api/index.ts'),
bundling: {
sourceMap: true,
target: 'es2020',
format: njs.OutputFormat.ESM, // <-- `njs.OutputFormat.CJS` works
mainFields: [ 'module', 'main' ]
},
environment: {
NODE_OPTIONS: '--enable-source-maps',
},
logRetention: logs.RetentionDays.TWO_WEEKS,
tracing: lambda.Tracing.ACTIVE
}); |
I'm also hitting this issue when bundling using esbuild, I'm not using cdk but my |
I also use commonjs bundles an run into this issue. How can I resolve this? |
I migrated to aws-sdk v3, thus I had to upgrade aws-xray-sdk-node because of I don't recommend to use it because is hacky & ugly. I also intent to remove it asap. Is there a plan how to tackle this issue? Thank you. |
it turned out that the redefinition of properties (https://github.com/aws/aws-xray-sdk-node/blob/master/packages/core/lib/patchers/http_p.js#L212) works on default export (while it doesn't when importing the entire module using |
I'm seeing the same issue after moving to esbuild from webpack. Reverting to 3.2.0 for the time being. |
Also just hit this. I have not been able to get the |
Any news about this issue ? having the same issue after moving to esbuild from webpack ! |
Hi all, I created a backlog item for us to investigate this issue. If you are able to share any reproduction code with us and include details about your environments, that would be very helpful! |
it's difficult for me to share all the code of my client but maybe I can extract some part. Can you tell me how I can help you and where to share some parts of the code ? |
This seems to be an issue related with migrating to ESM from CJS. More specifically, the The following summary in the OTel JS issue describes the problem clearly: There is no near-term plan for full ESM support in XRay SDK. However, in the linked OTel SDK discussion, an experimental feature was developed to support this ESM/import use case. OTel SDK is an alternative tracing instrumentation that can be used to send trace data to AWS XRay, and will need to be used alongside the ADOT Collector rather than the X-Ray Daemon. |
Add a wrapped fetch with minimal tracing support. Unfortunately we can't use the `AWSXRay` SDKs global instrumentation due to: aws/aws-xray-sdk-node#487 otherwise documented at https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs-httpclients.html
When packaging and running my AWS Lambda function using serverless + webpack with new versions of aws-sdk and aws-xray-sdk-core, I receive this error:
TypeError: Cannot redefine property: request
Package versions:
The text was updated successfully, but these errors were encountered: