@raytrace-cli/sdk 0.2.1 → 0.2.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +6 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytrace-cli/sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "TypeScript/JavaScript SDK for RayTrace cloud sandboxes: create, run commands, stop, start and destroy over the /v1 API",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.mjs CHANGED
@@ -58,7 +58,7 @@ export class Sandbox {
58
58
  { body: { command, timeout_seconds: timeoutSeconds, request_id: requestId } },
59
59
  );
60
60
  let job = created;
61
- while (!TERMINAL_STATES.has(job.state)) {
61
+ while (!TERMINAL_STATES.has(job.state) || job.recovery_pending) {
62
62
  await sleep(pollIntervalMs);
63
63
  const { data: latest } = await this._client.request(
64
64
  'GET',
@@ -110,12 +110,12 @@ export class Sandbox {
110
110
  await sleep(pollIntervalMs);
111
111
  const { data: list } = await this._client.request('GET', '/v1/sandboxes');
112
112
  const current = (list || []).find(item => item.id === this.id);
113
- if (!current) break;
113
+ if (!current) throw new RayTraceError(`Sandbox ${this.id} disappeared while restoring`, { status: 404 });
114
114
  this.info = current;
115
- if (current.status === 'running' || current.restore_error || current.status === 'archived') {
116
- if (current.restore_error) {
117
- throw new RayTraceError(`Archive restore failed: ${current.restore_error}`, { status: 500, body: current });
118
- }
115
+ if (current.restore_error) {
116
+ throw new RayTraceError(`Archive restore failed: ${current.restore_error}`, { status: 500, body: current });
117
+ }
118
+ if (!current.restoring && (current.status === 'running' || current.status === 'archived')) {
119
119
  break;
120
120
  }
121
121
  }