Skip to content

Object.defineProperty called on non-object when using @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb v3.778.0 in Node.js 18 Lambdas with externalModules #6991

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
1 task
salespace-momente opened this issue Mar 31, 2025 · 2 comments
Assignees
Labels
closed-for-staleness duplicate This issue is a duplicate. guidance General information and guidance, answers to FAQs, or recommended best practices/resources. p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Comments

@salespace-momente
Copy link

Describe the bug

After updating @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb to version 3.778.0, our Node.js 18 Lambdas that are configured with externalModules began throwing the following runtime error:

{ "errorType": "TypeError", "errorMessage": "Object.defineProperty called on non-object", "stack": [ "TypeError: Object.defineProperty called on non-object", " at defineProperty (<anonymous>)", " at __name (/var/task/index.js:37492:37)", " at <static_initializer> (/var/task/index.js:37618:9)", " at node_modules/@aws-sdk/lib-dynamodb/dist-cjs/index.js (/var/task/index.js:37616:85)", " at __require (/var/task/index.js:12:50)", " at Object.<anonymous> (/var/task/index.js:42071:35)", " at Module._compile (node:internal/modules/cjs/loader:1364:14)", " at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)", " at Module.load (node:internal/modules/cjs/loader:1203:32)", " at Module._load (node:internal/modules/cjs/loader:1019:12)" ] }

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The Lambda should initialize and execute correctly using the AWS SDK, as it did with previous versions (e.g., 3.776.0).

Current Behavior

The Lambda fails during import of @aws-sdk/lib-dynamodb, throwing a TypeError at runtime.

Reproduction Steps

Steps to Reproduce:
1. Create a Lambda function using Node.js 18 runtime.
2. Install @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb version 3.778.0.
3. Configure the bundler (e.g., esbuild) to treat these packages as externalModules.
4. Deploy and invoke the Lambda.

Possible Solution

The error seems to originate during import time from @aws-sdk/lib-dynamodb/dist-cjs/index.js, possibly related to recent changes involving __name or static initializers in the CJS bundle.

Additional Information/Context

Suspected Cause:
The error seems to originate during import time from @aws-sdk/lib-dynamodb/dist-cjs/index.js, possibly related to recent changes involving __name or static initializers in the CJS bundle.

SDK version used

3.778.0

Environment details (OS name and version, etc.)

macOS Sequoia 15.3.2

@salespace-momente salespace-momente added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 31, 2025
@aBurmeseDev aBurmeseDev transferred this issue from aws/aws-sdk-js Apr 1, 2025
@zshzbh zshzbh self-assigned this Apr 3, 2025
@zshzbh
Copy link
Contributor

zshzbh commented Apr 3, 2025

Hey @salespace-momente ,

It seems that updating esbuild to "esbuild": "0.18.20" resolves this issue. Please check similar issue here and here

Please let me know if this issue still exists after updating esbuild version.

Thanks!
Maggie

@zshzbh zshzbh added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Apr 3, 2025
@kuhe kuhe added duplicate This issue is a duplicate. guidance General information and guidance, answers to FAQs, or recommended best practices/resources. and removed bug This issue is a bug. labels Apr 3, 2025
Copy link

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Apr 14, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
closed-for-staleness duplicate This issue is a duplicate. guidance General information and guidance, answers to FAQs, or recommended best practices/resources. p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants