@computesdk/sandbox0 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -22578,6 +22578,12 @@ function isRetryable(error) {
|
|
|
22578
22578
|
const status = statusCode(error);
|
|
22579
22579
|
return status === 429 || status !== void 0 && status >= 500 && status <= 599;
|
|
22580
22580
|
}
|
|
22581
|
+
function isRateLimited(error) {
|
|
22582
|
+
return statusCode(error) === 429;
|
|
22583
|
+
}
|
|
22584
|
+
function isRuntimeNotReady(error) {
|
|
22585
|
+
return error instanceof Error && /not ready for this generation/i.test(error.message);
|
|
22586
|
+
}
|
|
22581
22587
|
function retryDelay(error, attempt) {
|
|
22582
22588
|
const retryAfter = error instanceof APIError ? error.retryAfter : void 0;
|
|
22583
22589
|
if (retryAfter !== void 0) {
|
|
@@ -22782,13 +22788,25 @@ var _provider = defineProvider({
|
|
|
22782
22788
|
const timeout = options?.timeout ?? observations.get(sandbox)?.commandTimeout;
|
|
22783
22789
|
const ttlSec = commandTimeoutSeconds(timeout);
|
|
22784
22790
|
const deadline = timeout !== void 0 && timeout > 0 ? startedAt + timeout : void 0;
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
22791
|
-
|
|
22791
|
+
let started;
|
|
22792
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
22793
|
+
try {
|
|
22794
|
+
started = await sandbox.cmd(command, {
|
|
22795
|
+
command: ["sh", "-lc", command],
|
|
22796
|
+
wait: false,
|
|
22797
|
+
cwd: options?.cwd,
|
|
22798
|
+
envVars: options?.env,
|
|
22799
|
+
ttlSec
|
|
22800
|
+
});
|
|
22801
|
+
break;
|
|
22802
|
+
} catch (error) {
|
|
22803
|
+
const remaining = deadline === void 0 ? Number.POSITIVE_INFINITY : deadline - Date.now();
|
|
22804
|
+
if (!isRuntimeNotReady(error) && !isRateLimited(error) || remaining <= 0 || attempt >= 5) {
|
|
22805
|
+
throw error;
|
|
22806
|
+
}
|
|
22807
|
+
await sleep(Math.min(retryDelay(error, attempt), Math.max(1, remaining)));
|
|
22808
|
+
}
|
|
22809
|
+
}
|
|
22792
22810
|
if (options?.background) {
|
|
22793
22811
|
return {
|
|
22794
22812
|
stdout: started.stdout || "",
|