@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.js
CHANGED
|
@@ -22598,6 +22598,12 @@ function isRetryable(error) {
|
|
|
22598
22598
|
const status = statusCode(error);
|
|
22599
22599
|
return status === 429 || status !== void 0 && status >= 500 && status <= 599;
|
|
22600
22600
|
}
|
|
22601
|
+
function isRateLimited(error) {
|
|
22602
|
+
return statusCode(error) === 429;
|
|
22603
|
+
}
|
|
22604
|
+
function isRuntimeNotReady(error) {
|
|
22605
|
+
return error instanceof Error && /not ready for this generation/i.test(error.message);
|
|
22606
|
+
}
|
|
22601
22607
|
function retryDelay(error, attempt) {
|
|
22602
22608
|
const retryAfter = error instanceof APIError ? error.retryAfter : void 0;
|
|
22603
22609
|
if (retryAfter !== void 0) {
|
|
@@ -22802,13 +22808,25 @@ var _provider = (0, import_provider.defineProvider)({
|
|
|
22802
22808
|
const timeout = options?.timeout ?? observations.get(sandbox)?.commandTimeout;
|
|
22803
22809
|
const ttlSec = commandTimeoutSeconds(timeout);
|
|
22804
22810
|
const deadline = timeout !== void 0 && timeout > 0 ? startedAt + timeout : void 0;
|
|
22805
|
-
|
|
22806
|
-
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
|
|
22810
|
-
|
|
22811
|
-
|
|
22811
|
+
let started;
|
|
22812
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
22813
|
+
try {
|
|
22814
|
+
started = await sandbox.cmd(command, {
|
|
22815
|
+
command: ["sh", "-lc", command],
|
|
22816
|
+
wait: false,
|
|
22817
|
+
cwd: options?.cwd,
|
|
22818
|
+
envVars: options?.env,
|
|
22819
|
+
ttlSec
|
|
22820
|
+
});
|
|
22821
|
+
break;
|
|
22822
|
+
} catch (error) {
|
|
22823
|
+
const remaining = deadline === void 0 ? Number.POSITIVE_INFINITY : deadline - Date.now();
|
|
22824
|
+
if (!isRuntimeNotReady(error) && !isRateLimited(error) || remaining <= 0 || attempt >= 5) {
|
|
22825
|
+
throw error;
|
|
22826
|
+
}
|
|
22827
|
+
await sleep(Math.min(retryDelay(error, attempt), Math.max(1, remaining)));
|
|
22828
|
+
}
|
|
22829
|
+
}
|
|
22812
22830
|
if (options?.background) {
|
|
22813
22831
|
return {
|
|
22814
22832
|
stdout: started.stdout || "",
|