@decocms/sandbox-controller 0.12.2 → 0.12.4

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.d.ts CHANGED
@@ -3835,6 +3835,12 @@ declare class FreestyleSandboxProvider implements SandboxProvider {
3835
3835
  private reclaim;
3836
3836
  /** True when it forked a repo snapshot: cloned, installed and serving. */
3837
3837
  private create;
3838
+ /**
3839
+ * Best-effort: a sandbox without org-fs still runs. Freestyle's edge can
3840
+ * answer 502 for a moment after a VM starts, even after the daemon took
3841
+ * its claim, and a missed relay leaves the turn without `/app/org`.
3842
+ */
3843
+ private relayOrgFsConfig;
3838
3844
  /**
3839
3845
  * The fork's first config: swap the snapshot's sentinel bearer for this
3840
3846
  * sandbox's own, retried until the new domain routes. A 401 means an earlier
package/dist/index.js CHANGED
@@ -610,8 +610,8 @@ function normalizeCoAuthorIdentity(input) {
610
610
 
611
611
  // ../sandbox/server/daemon-client.ts
612
612
  var ConfigRequestError = class extends Error {
613
- constructor(status, body) {
614
- super(`sandbox daemon /_sandbox/config returned ${status}: ${body}`);
613
+ constructor(status, body, endpoint = "/_sandbox/config") {
614
+ super(`sandbox daemon ${endpoint} returned ${status}: ${body}`);
615
615
  this.status = status;
616
616
  this.name = "ConfigRequestError";
617
617
  }
@@ -747,8 +747,10 @@ async function postOrgFsConfig(daemonUrl, token, configJson) {
747
747
  CONFIG_TIMEOUT_MS
748
748
  );
749
749
  if (!res.ok) {
750
- throw new Error(
751
- `sandbox daemon /_sandbox/orgfs-config returned ${res.status}: ${res.body}`
750
+ throw new ConfigRequestError(
751
+ res.status,
752
+ res.body,
753
+ "/_sandbox/orgfs-config"
752
754
  );
753
755
  }
754
756
  return parseJsonResponse(
@@ -6760,7 +6762,7 @@ var Freestyle = class {
6760
6762
  // ../sandbox/package.json
6761
6763
  var package_default = {
6762
6764
  name: "@decocms/sandbox",
6763
- version: "1.93.2",
6765
+ version: "1.93.4",
6764
6766
  private: true,
6765
6767
  type: "module",
6766
6768
  description: "Sandbox runtime for isolated Studio tool execution",
@@ -7260,11 +7262,11 @@ ${head}`).digest("hex").slice(0, 16)}`;
7260
7262
  await this.reclaim(found, sentinelSlug, opts);
7261
7263
  }
7262
7264
  if (opts.orgFsConfigJson) {
7263
- await postOrgFsConfig(
7265
+ await this.relayOrgFsConfig(
7264
7266
  found.daemon.url,
7265
7267
  found.daemon.token,
7266
7268
  opts.orgFsConfigJson
7267
- ).catch((err) => console.warn(`[${LOG_LABEL2}] org-fs relay failed`, err));
7269
+ );
7268
7270
  }
7269
7271
  const patch = gitCredentialRefreshPatch(opts);
7270
7272
  if (patch) {
@@ -7355,9 +7357,7 @@ ${head}`).digest("hex").slice(0, 16)}`;
7355
7357
  );
7356
7358
  step("claim");
7357
7359
  if (opts.orgFsConfigJson) {
7358
- await postOrgFsConfig(daemon.url, token, opts.orgFsConfigJson).catch(
7359
- (err) => console.warn(`[${LOG_LABEL2}] org-fs relay failed`, err)
7360
- );
7360
+ await this.relayOrgFsConfig(daemon.url, token, opts.orgFsConfigJson);
7361
7361
  }
7362
7362
  step("orgfs-config");
7363
7363
  console.log(
@@ -7372,6 +7372,19 @@ ${head}`).digest("hex").slice(0, 16)}`;
7372
7372
  this.remember(handle, { vm, daemon });
7373
7373
  return repoSnapshot !== null;
7374
7374
  }
7375
+ /**
7376
+ * Best-effort: a sandbox without org-fs still runs. Freestyle's edge can
7377
+ * answer 502 for a moment after a VM starts, even after the daemon took
7378
+ * its claim, and a missed relay leaves the turn without `/app/org`.
7379
+ */
7380
+ async relayOrgFsConfig(url, token, configJson) {
7381
+ await retry(() => postOrgFsConfig(url, token, configJson), {
7382
+ maxAttempts: 8,
7383
+ minTimeout: 250,
7384
+ maxTimeout: 4e3,
7385
+ isRetriable: (err) => err instanceof ConfigRequestError && err.status === 502
7386
+ }).catch((err) => console.warn(`[${LOG_LABEL2}] org-fs relay failed`, err));
7387
+ }
7375
7388
  /**
7376
7389
  * The fork's first config: swap the snapshot's sentinel bearer for this
7377
7390
  * sandbox's own, retried until the new domain routes. A 401 means an earlier
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/sandbox-controller",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "description": "Runs Studio agent sandboxes on Kubernetes, and serves them to a remote Studio.",
5
5
  "repository": {
6
6
  "type": "git",