Since adding aws-xray-sdk-core to my package dependencies, I'm getting the following warnings when bundling my package using webpack:
WARNING in ./node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js 41:32-47
Critical dependency: the request of a dependency is an expression
@ ./node_modules/aws-xray-sdk-core/lib/segments/attributes/aws.js
@ ./node_modules/aws-xray-sdk-core/lib/aws-xray.js
@ ./node_modules/aws-xray-sdk-core/lib/index.js
@ ./node_modules/aws-xray-sdk/lib/index.js
@ ./src/util/xray.ts
@ ./src/abc/def/xxx.ts
@ multi ./source-map-install.js ./src/abc/def/xxx.ts
WARNING in ./node_modules/colors/lib/colors.js 127:29-43
Critical dependency: the request of a dependency is an expression
@ ./node_modules/colors/safe.js
@ ./node_modules/winston/lib/winston/config.js
@ ./node_modules/winston/lib/winston.js
@ ./node_modules/aws-xray-sdk-core/lib/logger.js
@ ./node_modules/aws-xray-sdk-core/lib/context_utils.js
@ ./node_modules/aws-xray-sdk-core/lib/aws-xray.js
@ ./node_modules/aws-xray-sdk-core/lib/index.js
@ ./node_modules/aws-xray-sdk/lib/index.js
@ ./src/util/xray.ts
@ ./src/abc/def/xxx.ts
@ multi ./source-map-install.js ./src/abc/def/xxx.ts
Webpack tries to resolve require calls statically to make a minimal bundle. When a library uses variables in a require call (such as this line in aws-xrad-sdk-core), Webpack cannot resolve them statically and imports the entire package.
I'm using v2.2.0 of the SDK.
@jhecking
Thank you for reporting this. I'll have to dig into why we used a require to load a JSON file instead of the fs module, since changing that now could break if users were passing in a node module that contained their JSON.
However, when I commented out that line, and also the dynamic require in colors, the size of my bundle didn't decrease at all, so there doesn't appear to be any real gains in changing this (aside from removing the error messages.)
Thanks for looking into this. It's good to know that the bundle size is not affected. However, the warning messages are quite annoying.
The colors package has actually fixed the issue quite a while ago in Marak/colors.js#200. But it looks like you would have to update winston to v3.x in order to get the newer version and I think I saw some ticket about an incompatibility with that version?
Incompatibility here: https://github.com/aws/aws-xray-sdk-node/issues/48
Regardless, we should consider upgrading.
Glad I found this issue here but does your X-Ray tracing work despite the warnings?
I'm trying to run in Lambda with Webpack (typescript->JS) and while I see the same warnings it actually returns an error when I tried to execute:
"errorMessage": "Cannot read property 'customizeRequests' of undefined",
"errorType": "TypeError",
Usage:
const AWSXRay = require('aws-xray-sdk-core')
import { DynamoDB } from 'aws-sdk';
const client: DynamoDB.DocumentClient = new DynamoDB.DocumentClient();
// for the lack of types
AWSXRay.captureAWSClient((DynamoDB.DocumentClient as any).service);
Glad I found this issue here but does your X-Ray tracing work despite the warnings?
I'm trying to run in Lambda with Webpack (typescript->JS) and while I see the same warnings it actually returns an error when I tried to execute:
"errorMessage": "Cannot read property 'customizeRequests' of undefined", "errorType": "TypeError",Usage:
const AWSXRay = require('aws-xray-sdk-core') import { DynamoDB } from 'aws-sdk'; const client: DynamoDB.DocumentClient = new DynamoDB.DocumentClient(); // for the lack of types AWSXRay.captureAWSClient((DynamoDB.DocumentClient as any).service);
Nvm, managed to get it working now regardless of this warning, answer here in case anyone finds themselves in the same situation in the future:
const AWSXRay = require('aws-xray-sdk-core')
import { DocumentClient } from 'aws-sdk/clients/dynamodb';
let client: DocumentClient;
client = new DocumentClient();
AWSXRay.captureAWSClient((client as any).service);
Hello,
Is there an ETA to fix this? I'm looking at https://github.com/aws/aws-xray-sdk-node/blob/master/packages/core/CHANGELOG.md and I noticed that v2.4.0 was meant to fix this but I'm still seeing the issue on v.2.5.0.
https://github.com/aws/aws-xray-sdk-node/pull/190 appears to have been 'merged' but it's unclear when it will be released?
Thanks.
Hi @theshumanator,
The 3.0.0-alpha.1 is now released.
Most helpful comment
Nvm, managed to get it working now regardless of this warning, answer here in case anyone finds themselves in the same situation in the future: