Skip to content

Commit a9ec1a7

Browse files
fix: prevent api config overrides (#177)
* fix: prevent api config overrides * do not override baseUrl or fetch options, would be breaking
1 parent c5a8ffd commit a9ec1a7

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/utils/api.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export function createApiClient(
5050
fetch: (request) => enhanceFetch(request, instrumentation),
5151
...config,
5252
headers: {
53-
Authorization: `Bearer ${apiKey}`,
5453
...config.headers,
54+
Authorization: `Bearer ${apiKey}`,
5555
},
5656
})
5757
);
@@ -69,11 +69,14 @@ export function getStartOptions(opts: StartSandboxOpts | undefined) {
6969
if (!opts) return {};
7070

7171
// Warn about hibernation timeouts that are too short and may cause connection issues
72-
if (opts.hibernationTimeoutSeconds !== undefined && opts.hibernationTimeoutSeconds < 60) {
72+
if (
73+
opts.hibernationTimeoutSeconds !== undefined &&
74+
opts.hibernationTimeoutSeconds < 60
75+
) {
7376
console.warn(
7477
`Warning: hibernationTimeoutSeconds (${opts.hibernationTimeoutSeconds}s) is less than 60 seconds. ` +
75-
`This may cause connection instability and frequent disconnections. ` +
76-
`Consider using at least 60 seconds for stable websocket connections.`
78+
`This may cause connection instability and frequent disconnections. ` +
79+
`Consider using at least 60 seconds for stable websocket connections.`
7780
);
7881
}
7982

@@ -149,7 +152,10 @@ export function handleResponse<D, E>(
149152
}
150153

151154
if (result.response.status === 503) {
152-
throw new Error(errorPrefix + ": The sandbox is currently overloaded. Please review your logic to reduce the number of concurrent requests or try again in a moment.");
155+
throw new Error(
156+
errorPrefix +
157+
": The sandbox is currently overloaded. Please review your logic to reduce the number of concurrent requests or try again in a moment."
158+
);
153159
}
154160

155161
if ("error" in result) {

0 commit comments

Comments
 (0)