Skip to content

SDK V3.499.0 Bug while bundling using Webpack  #5728

Closed
@mskonf

Description

@mskonf

Checkboxes for prior research

Describe the bug

Any Projects using the AWS SDK Packages with version 3.499.0 when bundled and deployed lead to Webpack require issues after the recent change for use dynamic import for credential providers [(https://github.com//pull/5698) (1452cd45)

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v19.1.0

Reproduction Steps

Steps to Reproduce

  1. Please clone the repository Link
    This repository contains a small Serverless Project which uses @aws-sdk/[email protected] although it can be reproduced with any of the @AWS-SDK packages.
  2. After cloning, Install the packages
    npm install
  3. Bundle the files using Webpack
    npm run bundle
  4. Deploy the project
    serverless deploy --stage dev --region <REGION> ( I personally tried with ap-southeast-1 and ap-south-1)
  5. After deployment, a lambda function named listEvents and a events-table-dev DynamoDB table is created.
  6. For this small demo app, we can manually insert a record into the table say:
{
 "eventId": "8308b806-bf05-49f4-a61d-6c827554ca60",
 "eventName": "Dummy Event"
}

Now From the Lambda Console, please invoke using the test event as below

{
  "eventId": "8308b806-bf05-49f4-a61d-6c827554ca60"
}

Observed Behavior

Observed Behaviour

After we invoke the Lambda Function using the above test event
The following response is returned

{
  "statusCode": 500,
  "body": {
    "code": "MODULE_NOT_FOUND",
    "requireStack": [
      "/var/task/listEvents/index.js",
      "/var/runtime/index.mjs"
    ]
  }
}

Following is the detailed CloudWatch Log for the same

2024-01-26T05:33:33.656Z	513845a7-5bb9-4b32-8e30-5f7ccdb54bc8	INFO	Error: Cannot find module '../564/index.js'
Require stack:
- /var/task/listEvents/index.js
- /var/runtime/index.mjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at __webpack_require__.f.require (/var/task/listEvents/index.js:21535:28)
    at /var/task/listEvents/index.js:21474:40
    at Array.reduce (<anonymous>)
    at __webpack_require__.e (/var/task/listEvents/index.js:21473:67)
    at fromSSO.fromSSO (/var/task/listEvents/index.js:8859:59)
    at /var/task/listEvents/index.js:14871:39 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/var/task/listEvents/index.js', '/var/runtime/index.mjs' ]
}

The above error where it references a folder ../564/index.js is for the @aws-sdk/credential-provider-node while bundled.
This should be bundled within the index.js files if used. It didn't happen before this version(v3.499.0) release.
The issue is within the lambda runtime as we haven't included any of the AWS SDK Packages and are using the ones within the Lambda Runtime.

Expected Behavior

Expected Behaviour can be replicated by locally invoking the lambda as it doesn't use the bundled version of the files
Command To Get the Expected Response
serverless invoke local --function listEvents --data '{"eventId": "8308b806-bf05-49f4-a61d-6c827554ca60" }'
Response

{
    "statusCode": 200,
    "body": [
        {
            "eventId": "8308b806-bf05-49f4-a61d-6c827554ca60",
            "eventName": "Dummy Event"
        }
    ]
}

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

closed-for-stalenessguidanceGeneral information and guidance, answers to FAQs, or recommended best practices/resources.p2This is a standard priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions