Lately I have been getting an error that happens about once a week . maybe it is related to timeout of lambda or connection to monogoDB but I'm not sure. i using aws lambda and nodejs14 .
That is the Error:
2022-12-19T14:30:40.715Z 2a5e8a43-a315-40e2-a151-97b6630d9d95 ERROR Unhandled Promise Rejection {
"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 process.emit (domain.js:475:12)",
" at processPromiseRejections (internal/process/promises.js:245:33)",
" at processTicksAndRejections (internal/process/task_queues.js:96:32)"
]
}
The most of time there is no problem when i invoke the lambda .
my function:
const repository = new CustomerRepository();
export const getCustomers: any = middlewareBuilder(async (event, _context) => {
try {
logger.info('getCustomer start');
const customers = await repository.findAllCustomers(); // get data from db
logger.info({ message: ' fetch all customers ', additionalInfo: customers });
logger.info('getCustomer end ');
return httpResult(200, customers);
} catch (error) {
logger.error('error ' + error);
throw error;
}
});
I tried to upgrade nodejs14 to nodejs16.