Description
Describe the bug
Sporadically receiving the following error when trying to connect to DynamoDB from various different Lambda functions. This error does not consistently occur in any one particular Lambda function. We see this error occur in different Lambdas in our environment, but when it does occur it always in a Lambda attempting to connect to DynamoDB.
{
"errorType": "Error",
"errorMessage": "write EPROTO",
"code": "EPROTO",
"errno": -71,
"syscall": "write",
"$metadata": {
"attempts": 1,
"totalRetryDelay": 0
}
Your environment
SDK version number
"@aws-sdk/client-dynamodb": "^3.49.0",
"@aws-sdk/lib-dynamodb": "^3.49.0",
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
Lambda Node.js 14.x Runtime
Steps to reproduce
Cannot consistently reproduce, error occurs roughly once a week in our serverless environment. We have multiple Lambdas that access DynamoDB, and not all of them fail at the same time, but we have seen this error occur in all Lambdas that do access DynamoDB.
We use the following code to create the DynamoDB client. We then import the documentClient into the handler for each Lambda that needs access to DynamoDB.
import {DynamoDBDocumentClient} from "@aws-sdk/lib-dynamodb";
import {DynamoDBClient} from "@aws-sdk/client-dynamodb";
const dynamoDBClient = new DynamoDBClient({
});
const marshallOptions = {
// Whether to automatically convert empty strings, blobs, and sets to `null`.
convertEmptyValues: false, // false, by default.
// Whether to remove undefined values while marshalling.
removeUndefinedValues: true, // false, by default.
// Whether to convert typeof object to map attribute.
convertClassInstanceToMap: false, // false, by default.
};
const unmarshallOptions = {
// Whether to return numbers as a string instead of converting them to native JavaScript numbers.
wrapNumbers: false, // false, by default.
};
const translateConfig = { marshallOptions, unmarshallOptions };
export const documentClient = DynamoDBDocumentClient.from(dynamoDBClient, translateConfig);
Observed behavior
Receive the following error when trying to access DynamoDB with documentClient.send() with a GetItemCommand, QueryCommand, UpdateItemCommand, or PutItemCommand.
{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "Error: write EPROTO",
"reason": {
"errorType": "Error",
"errorMessage": "write EPROTO",
"code": "EPROTO",
"errno": -71,
"syscall": "write",
"$metadata": {
"attempts": 1,
"totalRetryDelay": 0
},
"stack": [
"Error: write EPROTO",
" at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:94:16)"
]
},
"promise": {},
"stack": [
"Runtime.UnhandledPromiseRejection: Error: write EPROTO",
" at process.<anonymous> (/var/runtime/index.js:35:15)",
" at process.emit (events.js:400:28)",
" at processPromiseRejections (internal/process/promises.js:245:33)",
" at processTicksAndRejections (internal/process/task_queues.js:96:32)"
]
}
Expected behavior
DocumentClient consistently able to access DynamoDB without throwing networking errors.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
I've viewed the following issues that have been previously opened that seem to be related to this issue, although most seem to be around 2016 in much earlier versions of the SDK and Node.js. Most recommendations are to force the secure protocol to TLSv1, but I don't imagine that would be the solution any longer as TLSv1.2 would be the recommended version.