Skip to content

Commit 3a972b0

Browse files
committed
feat(storage/s3): make S3 socket timeout configurable
The hardcoded socketTimeout: 3000 (introduced in d682bc0 along with stream-based downloads) aborts in-flight R2/S3 GetObject body sockets whenever the response stream is paused for >3s by backpressure from either the client response or the merge upload, surfacing as ECONNRESET on /download/<id>. Expose STORAGE_S3_SOCKET_TIMEOUT_MS so deployments hitting this can raise it without forking. Default kept at 3000 to preserve current behavior.
1 parent 16ac265 commit 3a972b0

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Release (penxle)
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*-penxle.*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Build and push image
12+
permissions:
13+
packages: write
14+
contents: read
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Get build hash
20+
id: build_hash
21+
run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
22+
23+
- name: Extract metadata
24+
id: meta
25+
uses: docker/metadata-action@v6
26+
with:
27+
images: ghcr.io/${{ github.repository }}
28+
tags: |
29+
type=ref,event=tag
30+
31+
- name: Login to GitHub Container Registry
32+
uses: docker/login-action@v4
33+
with:
34+
registry: ghcr.io
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v4
40+
41+
- name: Build and push
42+
uses: docker/build-push-action@v7
43+
with:
44+
context: .
45+
platforms: linux/arm64
46+
push: true
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}
49+
build-args: |
50+
BUILD_HASH=${{ steps.build_hash.outputs.COMMIT_SHA }}

lib/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const envStorageDriverSchema = type.or(
88
'AWS_ENDPOINT_URL?': 'string.url',
99
'AWS_ACCESS_KEY_ID?': 'string',
1010
'AWS_SECRET_ACCESS_KEY?': 'string',
11+
'STORAGE_S3_SOCKET_TIMEOUT_MS': 'number = 3000',
1112
},
1213
{
1314
STORAGE_DRIVER: type.unit('filesystem'),

lib/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ class S3Adapter implements StorageAdapter {
527527
region: env.AWS_REGION,
528528
requestHandler: new NodeHttpHandler({
529529
httpsAgent: agent,
530-
socketTimeout: 3000,
530+
socketTimeout: env.STORAGE_S3_SOCKET_TIMEOUT_MS,
531531
}),
532532
})
533533

0 commit comments

Comments
 (0)