AWS Lambda: set 500ms timeouts on s3 requests to work around latency spikes.

This commit is contained in:
Brandon Liu
2022-11-23 10:38:03 +08:00
parent 0e8d051933
commit f9a4848684
3 changed files with 10 additions and 4 deletions

View File

@@ -17,9 +17,13 @@ import https from "https";
import zlib from "zlib";
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
import { NodeHttpHandler } from "@aws-sdk/node-http-handler";
// the region should default to the same one as the function
const s3client = new S3Client({});
const s3client = new S3Client({requestHandler:new NodeHttpHandler({
connectionTimeout: 500,
socketTimeout: 500
})});
async function nativeDecompress(
buf: ArrayBuffer,