Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Create constant for keepalive header

Tomas Valenta81d349cb0b86
diff --git a/packages/js-sdk/src/connectionConfig.ts b/packages/js-sdk/src/connectionConfig.ts
index e325008d0..42f8e591e 100644
--- a/packages/js-sdk/src/connectionConfig.ts
+++ b/packages/js-sdk/src/connectionConfig.ts
@@ -4,6 +4,8 @@ import { getEnvVar } from './api/metadata'
const REQUEST_TIMEOUT_MS = 30_000 // 30s
export const KEEPALIVE_PING_INTERVAL_SEC = 50 // 50s
+export const KEEPALIVE_PING_HEADER = 'Keepalive-Ping-Interval'
+
export interface ConnectionOpts {
apiKey?: string
accessToken?: string
diff --git a/packages/js-sdk/src/sandbox/filesystem/index.ts b/packages/js-sdk/src/sandbox/filesystem/index.ts
index cb9bdea1f..a9f3ef838 100644
--- a/packages/js-sdk/src/sandbox/filesystem/index.ts
+++ b/packages/js-sdk/src/sandbox/filesystem/index.ts
@@ -11,6 +11,7 @@ import {
Username,
ConnectionOpts,
KEEPALIVE_PING_INTERVAL_SEC,
+ KEEPALIVE_PING_HEADER,
} from '../../connectionConfig'
import { handleEnvdApiError, handleWatchDirStartEvent } from '../../envd/api'
@@ -247,7 +248,7 @@ export class Filesystem {
const events = this.rpc.watchDir({ path }, {
headers: {
...authenticationHeader(opts?.user),
- 'Keepalive-Ping-Interval': KEEPALIVE_PING_INTERVAL_SEC.toString(),
+ [KEEPALIVE_PING_HEADER]: KEEPALIVE_PING_INTERVAL_SEC.toString(),
},
signal: controller.signal,
timeoutMs: opts?.timeout ?? this.defaultWatchTimeout,
diff --git a/packages/js-sdk/src/sandbox/process/index.ts b/packages/js-sdk/src/sandbox/process/index.ts
index f26a3fe0c..e21f571eb 100644
--- a/packages/js-sdk/src/sandbox/process/index.ts
+++ b/packages/js-sdk/src/sandbox/process/index.ts
@@ -12,7 +12,7 @@ import {
Signal,
ProcessConfig,
} from '../../envd/process/process_pb'
-import { ConnectionConfig, Username, ConnectionOpts, KEEPALIVE_PING_INTERVAL_SEC } from '../../connectionConfig'
+import { ConnectionConfig, Username, ConnectionOpts, KEEPALIVE_PING_INTERVAL_SEC, KEEPALIVE_PING_HEADER } from '../../connectionConfig'
import { authenticationHeader, handleRpcError } from '../../envd/rpc'
import { ProcessHandle, ProcessResult } from './processHandle'
import { handleProcessStartEvent } from '../../envd/api'
@@ -137,7 +137,7 @@ export class Process {
}, {
signal: controller.signal,
headers: {
- 'Keepalive-Ping-Interval': KEEPALIVE_PING_INTERVAL_SEC.toString(),
+ [KEEPALIVE_PING_HEADER]: KEEPALIVE_PING_INTERVAL_SEC.toString(),
},
timeoutMs: opts?.timeoutMs ?? this.defaultProcessConnectionTimeout,
})
@@ -192,7 +192,7 @@ export class Process {
}, {
headers: {
...authenticationHeader(opts?.user),
- 'Keepalive-Ping-Interval': KEEPALIVE_PING_INTERVAL_SEC.toString(),
+ [KEEPALIVE_PING_HEADER]: KEEPALIVE_PING_INTERVAL_SEC.toString(),
},
signal: controller.signal,
timeoutMs: opts?.timeoutMs ?? this.defaultProcessConnectionTimeout,