@meistrari/sandbox-sdk 1.0.6 → 1.0.8
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.cjs +12 -4
- package/dist/index.mjs +12 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -289,7 +289,7 @@ class SandboxClient {
|
|
|
289
289
|
throw await FetchError.from(url, "POST", res);
|
|
290
290
|
}
|
|
291
291
|
let capturedRunId;
|
|
292
|
-
let
|
|
292
|
+
let receivedTerminalEvent = false;
|
|
293
293
|
let stdoutCharsEmitted = 0;
|
|
294
294
|
let stderrCharsEmitted = 0;
|
|
295
295
|
const streamStartMs = Date.now();
|
|
@@ -301,6 +301,14 @@ class SandboxClient {
|
|
|
301
301
|
if (!run.isComplete) {
|
|
302
302
|
const elapsedMs = Date.now() - streamStartMs;
|
|
303
303
|
const remainingMs = timeoutMs - elapsedMs;
|
|
304
|
+
if (remainingMs <= 0) {
|
|
305
|
+
yield {
|
|
306
|
+
type: "error",
|
|
307
|
+
runId,
|
|
308
|
+
content: "Timeout exceeded before polling fallback could start"
|
|
309
|
+
};
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
304
312
|
const intervalMs = 500;
|
|
305
313
|
const maxAttempts = Math.max(1, Math.floor(remainingMs / intervalMs));
|
|
306
314
|
run = await run.waitForCompletion({ intervalMs, maxAttempts });
|
|
@@ -344,7 +352,7 @@ class SandboxClient {
|
|
|
344
352
|
capturedRunId = event.runId;
|
|
345
353
|
}
|
|
346
354
|
if (event.type === "done" || event.type === "error") {
|
|
347
|
-
|
|
355
|
+
receivedTerminalEvent = true;
|
|
348
356
|
}
|
|
349
357
|
if (event.type === "stdout" && event.content) {
|
|
350
358
|
stdoutCharsEmitted += event.content.length;
|
|
@@ -355,7 +363,7 @@ class SandboxClient {
|
|
|
355
363
|
yield event;
|
|
356
364
|
}
|
|
357
365
|
} catch (error) {
|
|
358
|
-
if (
|
|
366
|
+
if (receivedTerminalEvent) {
|
|
359
367
|
return;
|
|
360
368
|
}
|
|
361
369
|
if (!capturedRunId) {
|
|
@@ -364,7 +372,7 @@ class SandboxClient {
|
|
|
364
372
|
yield* recoverViaPolling(this, capturedRunId, stdoutCharsEmitted, stderrCharsEmitted);
|
|
365
373
|
return;
|
|
366
374
|
}
|
|
367
|
-
if (!
|
|
375
|
+
if (!receivedTerminalEvent && capturedRunId) {
|
|
368
376
|
yield* recoverViaPolling(this, capturedRunId, stdoutCharsEmitted, stderrCharsEmitted);
|
|
369
377
|
}
|
|
370
378
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -287,7 +287,7 @@ class SandboxClient {
|
|
|
287
287
|
throw await FetchError.from(url, "POST", res);
|
|
288
288
|
}
|
|
289
289
|
let capturedRunId;
|
|
290
|
-
let
|
|
290
|
+
let receivedTerminalEvent = false;
|
|
291
291
|
let stdoutCharsEmitted = 0;
|
|
292
292
|
let stderrCharsEmitted = 0;
|
|
293
293
|
const streamStartMs = Date.now();
|
|
@@ -299,6 +299,14 @@ class SandboxClient {
|
|
|
299
299
|
if (!run.isComplete) {
|
|
300
300
|
const elapsedMs = Date.now() - streamStartMs;
|
|
301
301
|
const remainingMs = timeoutMs - elapsedMs;
|
|
302
|
+
if (remainingMs <= 0) {
|
|
303
|
+
yield {
|
|
304
|
+
type: "error",
|
|
305
|
+
runId,
|
|
306
|
+
content: "Timeout exceeded before polling fallback could start"
|
|
307
|
+
};
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
302
310
|
const intervalMs = 500;
|
|
303
311
|
const maxAttempts = Math.max(1, Math.floor(remainingMs / intervalMs));
|
|
304
312
|
run = await run.waitForCompletion({ intervalMs, maxAttempts });
|
|
@@ -342,7 +350,7 @@ class SandboxClient {
|
|
|
342
350
|
capturedRunId = event.runId;
|
|
343
351
|
}
|
|
344
352
|
if (event.type === "done" || event.type === "error") {
|
|
345
|
-
|
|
353
|
+
receivedTerminalEvent = true;
|
|
346
354
|
}
|
|
347
355
|
if (event.type === "stdout" && event.content) {
|
|
348
356
|
stdoutCharsEmitted += event.content.length;
|
|
@@ -353,7 +361,7 @@ class SandboxClient {
|
|
|
353
361
|
yield event;
|
|
354
362
|
}
|
|
355
363
|
} catch (error) {
|
|
356
|
-
if (
|
|
364
|
+
if (receivedTerminalEvent) {
|
|
357
365
|
return;
|
|
358
366
|
}
|
|
359
367
|
if (!capturedRunId) {
|
|
@@ -362,7 +370,7 @@ class SandboxClient {
|
|
|
362
370
|
yield* recoverViaPolling(this, capturedRunId, stdoutCharsEmitted, stderrCharsEmitted);
|
|
363
371
|
return;
|
|
364
372
|
}
|
|
365
|
-
if (!
|
|
373
|
+
if (!receivedTerminalEvent && capturedRunId) {
|
|
366
374
|
yield* recoverViaPolling(this, capturedRunId, stdoutCharsEmitted, stderrCharsEmitted);
|
|
367
375
|
}
|
|
368
376
|
}
|