Skip to content

Commit ef46004

Browse files
mishushakovclaude
andauthored
feat: increase volume file upload timeout to 1 hour (#1248)
Increases the default timeout for volume `writeFile`/`write_file` operations from 60 seconds to 1 hour in both the JS and Python SDKs. Other volume operations retain the existing 60s default. Users can still override via `requestTimeoutMs` (JS) or `request_timeout` (Python). --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1cc385a commit ef46004

6 files changed

Lines changed: 43 additions & 7 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"e2b": patch
3+
"@e2b/python-sdk": patch
4+
---
5+
6+
Increase default timeout for volume file uploads to 1 hour

packages/js-sdk/src/volume/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { defaultHeaders, getEnvVar } from '../api/metadata'
55
import { createApiLogger, Logger } from '../logs'
66
import type { Volume } from './index'
77

8+
const FILE_TIMEOUT_MS = 3_600_000 // 1 hour
9+
810
export interface VolumeApiOpts {
911
/**
1012
* E2B API key to use for authentication.
@@ -111,4 +113,4 @@ class VolumeApiClient {
111113
}
112114

113115
export type { components as VolumeApiComponents, paths as VolumeApiPaths }
114-
export { VolumeApiClient }
116+
export { VolumeApiClient, FILE_TIMEOUT_MS }

packages/js-sdk/src/volume/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
VolumeApiComponents,
55
VolumeConnectionConfig,
66
VolumeApiOpts,
7+
FILE_TIMEOUT_MS,
78
} from './client'
89
import { ConnectionConfig, ConnectionOpts } from '../connectionConfig'
910
import { NotFoundError, VolumeError } from '../errors'
@@ -529,7 +530,7 @@ export class Volume {
529530
},
530531
},
531532
parseAs: format === 'bytes' ? 'arrayBuffer' : format,
532-
signal: config.getSignal(opts?.requestTimeoutMs),
533+
signal: config.getSignal(opts?.requestTimeoutMs ?? FILE_TIMEOUT_MS),
533534
})
534535

535536
if (res.response.status === 404) {
@@ -598,7 +599,7 @@ export class Volume {
598599
headers: {
599600
'Content-Type': 'application/octet-stream',
600601
},
601-
signal: config.getSignal(opts?.requestTimeoutMs),
602+
signal: config.getSignal(opts?.requestTimeoutMs ?? FILE_TIMEOUT_MS),
602603
})
603604

604605
if (res.response.status === 404) {

packages/python-sdk/e2b/volume/connection_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from e2b.api.metadata import package_version
99

1010
REQUEST_TIMEOUT: float = 60.0 # 60 seconds
11+
FILE_TIMEOUT: float = 3600.0 # 1 hour
1112

1213

1314
class VolumeApiParams(TypedDict, total=False):

packages/python-sdk/e2b/volume/volume_async.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from typing import AsyncIterator, IO, List, Literal, Optional, Union, cast, overload
22
from http import HTTPStatus
33

4+
import httpx
5+
46
from typing_extensions import Unpack
57

68
from e2b.api import handle_api_exception
@@ -33,7 +35,11 @@
3335
)
3436
from e2b.volume.client.types import File as FilePayload, UNSET
3537
from e2b.volume.client_async import get_api_client as get_volume_api_client
36-
from e2b.volume.connection_config import VolumeApiParams, VolumeConnectionConfig
38+
from e2b.volume.connection_config import (
39+
VolumeApiParams,
40+
VolumeConnectionConfig,
41+
FILE_TIMEOUT,
42+
)
3743
from e2b.volume.types import (
3844
VolumeAndToken,
3945
VolumeInfo,
@@ -457,7 +463,9 @@ async def read_file(
457463
api_client = get_volume_api_client(config)
458464

459465
params = {"path": path}
460-
timeout = config.get_request_timeout(opts.get("request_timeout"))
466+
timeout = VolumeConnectionConfig._get_request_timeout(
467+
FILE_TIMEOUT, opts.get("request_timeout")
468+
)
461469

462470
if format == "stream":
463471

@@ -536,7 +544,12 @@ async def write_file(
536544
:return: Information about the written file
537545
"""
538546
config = self._get_volume_config(**opts)
547+
upload_timeout = VolumeConnectionConfig._get_request_timeout(
548+
FILE_TIMEOUT, opts.get("request_timeout")
549+
)
539550
api_client = get_volume_api_client(config)
551+
if upload_timeout is not None:
552+
api_client = api_client.with_timeout(httpx.Timeout(upload_timeout))
540553

541554
if isinstance(data, str):
542555
data_bytes = data.encode("utf-8")

packages/python-sdk/e2b/volume/volume_sync.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from typing import IO, Iterator, List, Literal, Optional, Union, cast, overload
22
from http import HTTPStatus
33

4+
import httpx
5+
46
from typing_extensions import Unpack
57

68
from e2b.api import handle_api_exception
@@ -33,7 +35,11 @@
3335
)
3436
from e2b.volume.client.types import File as FilePayload, UNSET
3537
from e2b.volume.client_sync import get_api_client as get_volume_api_client
36-
from e2b.volume.connection_config import VolumeApiParams, VolumeConnectionConfig
38+
from e2b.volume.connection_config import (
39+
VolumeApiParams,
40+
VolumeConnectionConfig,
41+
FILE_TIMEOUT,
42+
)
3743
from e2b.volume.types import (
3844
VolumeAndToken,
3945
VolumeInfo,
@@ -455,7 +461,9 @@ def read_file(
455461
api_client = get_volume_api_client(config)
456462

457463
params = {"path": path}
458-
timeout = config.get_request_timeout(opts.get("request_timeout"))
464+
timeout = VolumeConnectionConfig._get_request_timeout(
465+
FILE_TIMEOUT, opts.get("request_timeout")
466+
)
459467

460468
if format == "stream":
461469

@@ -533,7 +541,12 @@ def write_file(
533541
:return: Information about the written file
534542
"""
535543
config = self._get_volume_config(**opts)
544+
upload_timeout = VolumeConnectionConfig._get_request_timeout(
545+
FILE_TIMEOUT, opts.get("request_timeout")
546+
)
536547
api_client = get_volume_api_client(config)
548+
if upload_timeout is not None:
549+
api_client = api_client.with_timeout(httpx.Timeout(upload_timeout))
537550

538551
if isinstance(data, str):
539552
data_bytes = data.encode("utf-8")

0 commit comments

Comments
 (0)