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

@salespace-momente

Description

@salespace-momente

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

Metadata

Metadata

Assignees

Labels

closed-for-stalenessduplicateThis issue is a duplicate.guidanceGeneral information and guidance, answers to FAQs, or recommended best practices/resources.p2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions