@astrale-os/adapter-cloudflare 0.5.0-beta.195 → 0.5.0-beta.197

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/README.md CHANGED
@@ -179,6 +179,11 @@ takes one, and deployment refuses a secret that does. A host that deploys the Wo
179
179
  the settings with `encodeWorkerSettings` from `@astrale-os/adapter-cloudflare/worker`. A generated
180
180
  Worker refuses execution without `ASTRALE_SETTINGS`.
181
181
 
182
+ `maximumRequestBytes` bounds the invocation bodies the Worker buffers. A streamed binary body is
183
+ bounded by the Build instead: the largest `maximumBytes` among the Domain's binary Functions, with
184
+ 30 minutes to arrive (or `invocationTimeoutMs` when longer) and at most 60 seconds between chunks.
185
+ A Domain without a binary Function keeps the Kernel Server defaults.
186
+
182
187
  Every Worker requires `WORKER_URL` and `ASTRALE_BUILD_DIGEST`. It seals the `DomainRelease` v4
183
188
  of its code at that serving URL, which is also its issuer, and serves it at
184
189
  `/.well-known/astrale/release.json`. Routing must name that exact Release. The Worker refuses
package/dist/params.d.ts CHANGED
@@ -27,13 +27,17 @@ export interface CloudflareParams {
27
27
  /**
28
28
  * Maximum encoded invocation request bytes retained by the Worker Server.
29
29
  * Defaults to 1 MiB and is capped at 16 MiB. Increase only from measured
30
- * application traffic; Release and Bundle delivery have separate limits.
30
+ * application traffic; Release and Bundle delivery have separate limits. A streamed
31
+ * binary request is not retained: it is capped by the largest `maximumBytes` among
32
+ * the Domain's binary Functions instead.
31
33
  */
32
34
  readonly maximumRequestBytes?: number;
33
35
  /**
34
36
  * Maximum wall-clock lifetime of one invocation, including Workflow steps and
35
37
  * returned streams. Defaults to 30 seconds. Increase this for intentionally
36
- * long provider orchestration while retaining a finite application budget.
38
+ * long provider orchestration while retaining a finite application budget. A binary
39
+ * request of a Domain with binary Functions lives up to 30 minutes, or this budget
40
+ * when it is longer.
37
41
  */
38
42
  readonly invocationTimeoutMs?: number;
39
43
  /**
@@ -0,0 +1,21 @@
1
+ import type { Build } from '@astrale-os/sdk/deployment/build';
2
+ /**
3
+ * Lifetime of one streamed binary request, upload included: the Kernel's own Server gives a blob
4
+ * upload the same 30 minutes.
5
+ */
6
+ export declare const BINARY_REQUEST_TIMEOUT_MS: number;
7
+ /** Longest wait for the next chunk of a binary body while the Action reads it, as the Kernel's. */
8
+ export declare const BINARY_REQUEST_IDLE_TIMEOUT_MS = 60000;
9
+ /** The Kernel Server limits a Worker serves binary requests under. */
10
+ export interface BinaryRequestLimits {
11
+ readonly maximumBinaryRequestBytes: number;
12
+ readonly binaryRequestTimeoutMs: number;
13
+ readonly binaryRequestIdleTimeoutMs: number;
14
+ }
15
+ /**
16
+ * The streamed binary request budget of one Build: the largest `maximumBytes` among the binary
17
+ * Functions its Domain declares, so the deployment admits every body one of them accepts and
18
+ * admission still holds each Function to its own. A Build without a binary Function keeps the
19
+ * Kernel Server defaults: `maximumRequestBytes` and `invocationTimeoutMs`.
20
+ */
21
+ export declare function binaryRequestLimits(build: Pick<Build, 'schema'>, invocationTimeoutMs: number): BinaryRequestLimits | undefined;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Lifetime of one streamed binary request, upload included: the Kernel's own Server gives a blob
3
+ * upload the same 30 minutes.
4
+ */
5
+ export const BINARY_REQUEST_TIMEOUT_MS = 30 * 60_000;
6
+ /** Longest wait for the next chunk of a binary body while the Action reads it, as the Kernel's. */
7
+ export const BINARY_REQUEST_IDLE_TIMEOUT_MS = 60_000;
8
+ /**
9
+ * The streamed binary request budget of one Build: the largest `maximumBytes` among the binary
10
+ * Functions its Domain declares, so the deployment admits every body one of them accepts and
11
+ * admission still holds each Function to its own. A Build without a binary Function keeps the
12
+ * Kernel Server defaults: `maximumRequestBytes` and `invocationTimeoutMs`.
13
+ */
14
+ export function binaryRequestLimits(build, invocationTimeoutMs) {
15
+ const compiled = build.schema.compiled;
16
+ const root = compiled.closure.find(({ origin }) => origin === compiled.root.origin);
17
+ let maximumBytes;
18
+ for (const definition of root?.definitions.functions ?? []) {
19
+ if (typeof definition.input === 'number')
20
+ continue;
21
+ maximumBytes = Math.max(maximumBytes ?? 0, definition.input.maximumBytes);
22
+ }
23
+ if (maximumBytes === undefined)
24
+ return undefined;
25
+ return Object.freeze({
26
+ maximumBinaryRequestBytes: maximumBytes,
27
+ // A deployment that already grants every invocation longer keeps that budget for uploads.
28
+ binaryRequestTimeoutMs: Math.max(invocationTimeoutMs, BINARY_REQUEST_TIMEOUT_MS),
29
+ binaryRequestIdleTimeoutMs: BINARY_REQUEST_IDLE_TIMEOUT_MS,
30
+ });
31
+ }
@@ -2,6 +2,7 @@ import { issuer } from '@astrale-os/sdk/auth';
2
2
  import { restoreBuild, restoreGeneratedBuild } from '@astrale-os/sdk/deployment/build/material';
3
3
  import { assemble } from '@astrale-os/sdk/deployment/release/runtime';
4
4
  import { createIdentity, serve } from '@astrale-os/sdk/execution';
5
+ import { binaryRequestLimits } from './binary.js';
5
6
  import { deploymentBuildDigest } from './build-digest.js';
6
7
  import { cloudflareCache } from './cache.js';
7
8
  import { dispatchCloudflareRequest, prepareCloudflareRequest } from './fetch.js';
@@ -46,6 +47,7 @@ function createCloudflareWorkerEntry(restore) {
46
47
  const { build } = source;
47
48
  const settings = config.settings === undefined ? config : config.settings(bindings);
48
49
  const buildDigest = deploymentBuildDigest(bindings);
50
+ const invocationTimeoutMs = settings.invocationTimeoutMs ?? DEFAULT_INVOCATION_TIMEOUT_MS;
49
51
  const created = serve({
50
52
  runtime: source.runtime,
51
53
  load(environment) {
@@ -86,7 +88,10 @@ function createCloudflareWorkerEntry(restore) {
86
88
  maximumReleaseBytes: 1024 * 1024,
87
89
  maximumBundleBytes: 8 * 1024 * 1024,
88
90
  maximumDeliveryBytes: 8 * 1024 * 1024,
89
- invocationTimeoutMs: settings.invocationTimeoutMs ?? DEFAULT_INVOCATION_TIMEOUT_MS,
91
+ invocationTimeoutMs,
92
+ // Streamed binary bodies are never buffered, so their cap follows the Domain's binary
93
+ // Functions instead of maximumRequestBytes.
94
+ ...binaryRequestLimits(build, invocationTimeoutMs),
90
95
  },
91
96
  },
92
97
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/adapter-cloudflare",
3
- "version": "0.5.0-beta.195",
3
+ "version": "0.5.0-beta.197",
4
4
  "description": "Deploy an Astrale Domain through Cloudflare Workers",
5
5
  "keywords": [
6
6
  "adapter",
@@ -61,7 +61,7 @@
61
61
  "registry": "https://registry.npmjs.org/"
62
62
  },
63
63
  "dependencies": {
64
- "@astrale-os/sdk": "0.6.0-beta.40",
64
+ "@astrale-os/sdk": "0.6.0-beta.42",
65
65
  "@noble/hashes": "2.3.0",
66
66
  "@restatedev/restate-sdk-cloudflare-workers": "1.17.0",
67
67
  "hono": "^4.6.20",