Skip to content

Commit 8ac9a31

Browse files
committed
turn on automatic retries
1 parent 72b5c73 commit 8ac9a31

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

packages/js-sdk/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"chalk": "^5.3.0",
9696
"compare-versions": "^6.1.0",
9797
"dockerfile-ast": "^0.7.1",
98+
"fetch-retry": "^6.0.0",
9899
"glob": "^11.0.3",
99100
"openapi-fetch": "^0.14.1",
100101
"platform": "^1.3.6",

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createConnectTransport } from '@connectrpc/connect-web'
2+
import fetchRetry from 'fetch-retry'
23

34
import {
45
ConnectionConfig,
@@ -127,6 +128,11 @@ export class Sandbox extends SandboxApi {
127128
this.connectionConfig.debug ? 'http' : 'https'
128129
}://${this.getHost(this.envdPort)}`
129130

131+
const fetchWithRetries = fetchRetry(fetch, {
132+
retries: 3,
133+
retryDelay: 500,
134+
})
135+
130136
const rpcTransport = createConnectTransport({
131137
baseUrl: this.envdApiUrl,
132138
useBinaryFormat: false,
@@ -152,7 +158,7 @@ export class Sandbox extends SandboxApi {
152158
redirect: 'follow',
153159
}
154160

155-
return fetch(url, options)
161+
return fetchWithRetries(url, options)
156162
},
157163
})
158164

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)