mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 19:01:08 +00:00
AWS Lambda: set 500ms timeouts on s3 requests to work around latency spikes.
This commit is contained in:
3
serverless/aws/package-lock.json
generated
3
serverless/aws/package-lock.json
generated
@@ -8,7 +8,8 @@
|
|||||||
"name": "pmtiles-aws",
|
"name": "pmtiles-aws",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.213.0"
|
"@aws-sdk/client-s3": "^3.213.0",
|
||||||
|
"@aws-sdk/node-http-handler": "^3.212.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/aws-lambda": "^8.10.108",
|
"@types/aws-lambda": "^8.10.108",
|
||||||
|
|||||||
@@ -10,9 +10,10 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"tsc": "tsc --noEmit --watch",
|
"tsc": "tsc --noEmit --watch",
|
||||||
"build": "esbuild src/index.ts --target=es2020 --outfile=dist/index.mjs --format=esm --bundle --platform=node --target=node18 --external:@aws-sdk/client-s3 --banner:js=//$(git describe --always) && cd dist && zip lambda_function.zip index.mjs"
|
"build": "esbuild src/index.ts --target=es2020 --outfile=dist/index.mjs --format=esm --bundle --platform=node --target=node18 --external:@aws-sdk/client-s3 --external:@aws-sdk/node-http-handler --banner:js=//$(git describe --always) && cd dist && zip lambda_function.zip index.mjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.213.0"
|
"@aws-sdk/client-s3": "^3.213.0",
|
||||||
|
"@aws-sdk/node-http-handler": "^3.212.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,13 @@ import https from "https";
|
|||||||
import zlib from "zlib";
|
import zlib from "zlib";
|
||||||
|
|
||||||
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
|
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
|
// 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(
|
async function nativeDecompress(
|
||||||
buf: ArrayBuffer,
|
buf: ArrayBuffer,
|
||||||
|
|||||||
Reference in New Issue
Block a user