@keska/sandbox 0.42.0 → 0.43.0

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/dist/index.js +28 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -365,6 +365,31 @@ function writeTar(files) {
365
365
  return Buffer.concat(chunks);
366
366
  }
367
367
 
368
+ // ../sdk-shared-ts/src/heartbeat.ts
369
+ var IMAGE_BUILD_HEARTBEAT_MS = 15e3;
370
+ function startImageBuildHeartbeat(opts) {
371
+ const intervalMs = opts?.intervalMs ?? IMAGE_BUILD_HEARTBEAT_MS;
372
+ const write2 = opts?.write ?? ((line) => process.stderr.write(`${line}
373
+ `));
374
+ const schedule = opts?.schedule ?? ((tick, ms) => {
375
+ const id = setInterval(tick, ms);
376
+ return { cancel: () => clearInterval(id) };
377
+ });
378
+ write2("building image...");
379
+ let ticks = 0;
380
+ let stopped = false;
381
+ const step = Math.round(intervalMs / 1e3);
382
+ const handle = schedule(() => {
383
+ if (stopped) return;
384
+ ticks += 1;
385
+ write2(`building image... ${ticks * step}s`);
386
+ }, intervalMs);
387
+ return () => {
388
+ stopped = true;
389
+ handle.cancel();
390
+ };
391
+ }
392
+
368
393
  // ../sdk-shared-ts/src/errors.ts
369
394
  var SandboxError = class extends Error {
370
395
  code;
@@ -2713,6 +2738,7 @@ var Session = class {
2713
2738
  };
2714
2739
  }
2715
2740
  }
2741
+ const stopHeartbeat = startImageBuildHeartbeat();
2716
2742
  try {
2717
2743
  const res = await this.svc.buildImage(chunks(), {
2718
2744
  signal: opts.signal,
@@ -2727,6 +2753,8 @@ var Session = class {
2727
2753
  });
2728
2754
  } catch (error) {
2729
2755
  throw mapConnectError(error, opts.timeoutMs ?? 6e5);
2756
+ } finally {
2757
+ stopHeartbeat();
2730
2758
  }
2731
2759
  }
2732
2760
  async getImage(name, opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keska/sandbox",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "TypeScript client for the Numen sandbox API",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",