aws-sdk-js-v3
aws-sdk-js-v3 copied to clipboard
'@smithy/node-http-handler' not included in lambda Node.js 20.x runtime
Checkboxes for prior research
- [X] I've gone through Developer Guide and API reference
- [X] I've checked AWS Forums and StackOverflow.
- [X] I've searched for previous similar issues and didn't find any solution.
Describe the bug
The documentation at https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/CLIENTS.md#request-handler-requesthandler says to use '@smithy/node-http-handler' but the lambda fails with "errorMessage": "Cannot find package '@smithy/node-http-handler' imported from /var/task/index.mjs", "code": "ERR_MODULE_NOT_FOUND"
, regardless of whether the module is specified as a dependency in package.json or not.
SDK version number
@aws-sdk/client-s3 3.4x and 3.5x
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
Node.js v20
Reproduction Steps
import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
import { NodeHttpHandler } from '@smithy/node-http-handler';
const s3 = new S3Client({
requestHandler: new NodeHttpHandler({
httpsAgent: new https.Agent({
maxSockets: 150,
}),
})
});
[...]
Observed Behavior
2024-06-05T19:28:48.275Z undefined ERROR Uncaught Exception
{
"errorType": "Error",
"errorMessage": "Cannot find package '@smithy/node-http-handler' imported from /var/task/index.mjs",
"code": "ERR_MODULE_NOT_FOUND",
"stack": [
"Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@smithy/node-http-handler' imported from /var/task/index.mjs",
" at packageResolve (node:internal/modules/esm/resolve:858:9)",
" at moduleResolve (node:internal/modules/esm/resolve:931:18)",
" at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1161:14)",
" at defaultResolve (node:internal/modules/esm/resolve:1204:79)",
" at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)",
" at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)",
" at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)",
" at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)",
" at link (node:internal/modules/esm/module_job:86:36)"
]
}
Expected Behavior
Module should be found.
Possible Solution
Workaround is to use
import { NodeHttpHandler } from '@aws-sdk/node-http-handler';
instead.
Additional Information/Context
No response