@norskvideo/ctl-sdk 0.1.22 → 0.1.23

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.
@@ -17,7 +17,18 @@ export declare function specBaseUrl(spec: ProductSpec, port?: number, reachHost?
17
17
  * so a recorded reachHost is never forgotten. */
18
18
  export declare function productBaseUrl(reg: Pick<ProductRegistration, "spec" | "port" | "reachHost">): string;
19
19
  export declare function fetchManifest(baseUrl: string): Promise<Manifest>;
20
- export declare function waitForReady(baseUrl: string): Promise<void>;
20
+ /** Poll a product's manifest until it answers.
21
+ *
22
+ * The timeout names `baseUrl`. That is the whole point of the message: the
23
+ * daemon dials a container product on loopback, and where that loopback is not
24
+ * the daemon's own (a docker-outside-of-docker runner, where it belongs to the
25
+ * docker host — see product-reach.ts) the product is perfectly healthy and
26
+ * simply unreachable. Without the address, that reads identically to a product
27
+ * that genuinely failed to start. */
28
+ export declare function waitForReady(baseUrl: string, opts?: {
29
+ timeoutMs?: number;
30
+ intervalMs?: number;
31
+ }): Promise<void>;
21
32
  /**
22
33
  * Probe the product's configScreenUrl after registration. Two hard
23
34
  * rejections:
package/manifest-fetch.js CHANGED
@@ -56,8 +56,18 @@ export async function fetchManifest(baseUrl) {
56
56
  }
57
57
  return parsed.data;
58
58
  }
59
- export async function waitForReady(baseUrl) {
60
- const deadline = Date.now() + READINESS_TIMEOUT_MS;
59
+ /** Poll a product's manifest until it answers.
60
+ *
61
+ * The timeout names `baseUrl`. That is the whole point of the message: the
62
+ * daemon dials a container product on loopback, and where that loopback is not
63
+ * the daemon's own (a docker-outside-of-docker runner, where it belongs to the
64
+ * docker host — see product-reach.ts) the product is perfectly healthy and
65
+ * simply unreachable. Without the address, that reads identically to a product
66
+ * that genuinely failed to start. */
67
+ export async function waitForReady(baseUrl, opts = {}) {
68
+ const timeoutMs = opts.timeoutMs ?? READINESS_TIMEOUT_MS;
69
+ const intervalMs = opts.intervalMs ?? READINESS_INTERVAL_MS;
70
+ const deadline = Date.now() + timeoutMs;
61
71
  while (Date.now() < deadline) {
62
72
  try {
63
73
  const r = await fetch(`${baseUrl}/manifest.json`);
@@ -67,9 +77,9 @@ export async function waitForReady(baseUrl) {
67
77
  catch {
68
78
  // not ready yet
69
79
  }
70
- await new Promise((resolve) => setTimeout(resolve, READINESS_INTERVAL_MS));
80
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
71
81
  }
72
- throw new ProductError("READINESS_TIMEOUT", `product did not become ready within ${READINESS_TIMEOUT_MS}ms`);
82
+ throw new ProductError("READINESS_TIMEOUT", `product did not become ready within ${timeoutMs}ms — nothing answered ${baseUrl}/manifest.json`);
73
83
  }
74
84
  /**
75
85
  * Probe the product's configScreenUrl after registration. Two hard
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norskvideo/ctl-sdk",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -37,7 +37,7 @@
37
37
  "types": "./index.d.ts",
38
38
  "dependencies": {
39
39
  "@norskvideo/ctl-foundation": "^0.1.0",
40
- "@norskvideo/ctl-product-template-schema": "^0.1.5",
40
+ "@norskvideo/ctl-product-template-schema": "^0.1.12",
41
41
  "express": "5",
42
42
  "lucide-react": "^0.483.0",
43
43
  "react": "^19.0.0",
@@ -127,7 +127,7 @@ export class ProductService {
127
127
  }
128
128
  port = allocated;
129
129
  await this.refreshImage(spec.image);
130
- logger.info(`Starting product container: ${spec.image} on host port ${port}`);
130
+ logger.info(`Starting product container: ${spec.image} on host port ${port} (reach: ${this.reach})`);
131
131
  containerId = await this.containerOps.run(spec.image, port);
132
132
  reachHost = await this.reachHostFor(containerId);
133
133
  baseUrl = specBaseUrl(spec, port, reachHost);