@moinulmoin/eden-runtime-cloudflare 0.11.2 → 0.11.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/eden-eve-host-worker.mjs +26 -13
- package/dist/eve-host-runtime.d.ts +1 -1
- package/dist/eve-host-runtime.js +33 -14
- package/package.json +2 -2
|
@@ -26159,6 +26159,12 @@ var EVE_HOST_CARRY_LIMITS = {
|
|
|
26159
26159
|
chunkBytes: 1024 * 1024,
|
|
26160
26160
|
maxBytes: 1024 * 1024 * 1024
|
|
26161
26161
|
};
|
|
26162
|
+
var EveSandboxCarryLimitError = class extends Error {
|
|
26163
|
+
constructor() {
|
|
26164
|
+
super("The imported sandbox carry exceeds the archive limit.");
|
|
26165
|
+
this.name = "EveSandboxCarryLimitError";
|
|
26166
|
+
}
|
|
26167
|
+
};
|
|
26162
26168
|
var EVE_HOST_SNAPSHOT_MAX_ATTEMPTS = 3;
|
|
26163
26169
|
function isMissingContainerSnapshot(error61) {
|
|
26164
26170
|
return error61 instanceof Error && /Snapshot ".*" was not found/u.test(error61.message);
|
|
@@ -26206,7 +26212,7 @@ var EdenWorldDurableObject = class extends DurableObject {
|
|
|
26206
26212
|
if (message.sourceDeploymentId && message.sourceDeploymentId !== deploymentId && message.sandboxSessionId) {
|
|
26207
26213
|
try {
|
|
26208
26214
|
const result = await target2.importSandboxSessions(message.sourceDeploymentId, deploymentId, message.messageId, message.sandboxSessionId);
|
|
26209
|
-
if (result === "source-export-failed") {
|
|
26215
|
+
if (result === "source-export-failed" || result === "carry-limit-exceeded") {
|
|
26210
26216
|
await settleUnstarted();
|
|
26211
26217
|
return { ok: false, sandboxTransferFailed: true };
|
|
26212
26218
|
}
|
|
@@ -26295,16 +26301,13 @@ async function routeEveOutboundRequest(request, env, sourceDeploymentId, expecte
|
|
|
26295
26301
|
if (env.EDEN_EVE_DEPLOYMENTS !== void 0 && route === void 0) {
|
|
26296
26302
|
return new Response("Deployment retired; its sessions ended.", { status: 403 });
|
|
26297
26303
|
}
|
|
26298
|
-
const
|
|
26299
|
-
|
|
26300
|
-
|
|
26301
|
-
|
|
26302
|
-
|
|
26303
|
-
|
|
26304
|
-
|
|
26305
|
-
if (expected.length === 0 || actual.length !== expected.length || !subtle.timingSafeEqual(actual, expected)) {
|
|
26306
|
-
return new Response(null, { status: 403 });
|
|
26307
|
-
}
|
|
26304
|
+
const supplied = request.headers.get("x-eden-world-token") ?? "";
|
|
26305
|
+
const encoder = new TextEncoder();
|
|
26306
|
+
const expected = encoder.encode(expectedWorldToken ?? "");
|
|
26307
|
+
const actual = encoder.encode(supplied);
|
|
26308
|
+
const subtle = crypto.subtle;
|
|
26309
|
+
if (expected.length === 0 || actual.length !== expected.length || !subtle.timingSafeEqual(actual, expected)) {
|
|
26310
|
+
return new Response(null, { status: 403 });
|
|
26308
26311
|
}
|
|
26309
26312
|
const world = env.EDEN_WORLD;
|
|
26310
26313
|
if (world === void 0) return new Response(null, { status: 404 });
|
|
@@ -26803,7 +26806,7 @@ var EveHostDurableContainer = class extends DurableObject {
|
|
|
26803
26806
|
await reader.cancel().catch(() => void 0);
|
|
26804
26807
|
if (overflowed) {
|
|
26805
26808
|
await discardWrittenChunks();
|
|
26806
|
-
if (required2) throw new
|
|
26809
|
+
if (required2) throw new EveSandboxCarryLimitError();
|
|
26807
26810
|
console.error(
|
|
26808
26811
|
`The Eve sandbox session carry exceeded ${EVE_HOST_CARRY_LIMITS.maxBytes} compressed bytes; keeping the previous carry.`
|
|
26809
26812
|
);
|
|
@@ -27129,7 +27132,17 @@ var EveHostDurableContainer = class extends DurableObject {
|
|
|
27129
27132
|
const errorText = publish.stderr === null ? "" : await new Response(publish.stderr).text();
|
|
27130
27133
|
if (await publish.exitCode !== 0) throw new Error(`Sandbox import refused: ${errorText.trim()}; staging retained at ${stage}.`);
|
|
27131
27134
|
await this.ctx.storage.delete(EVE_HOST_CONTAINER_SNAPSHOT_KEY);
|
|
27132
|
-
|
|
27135
|
+
try {
|
|
27136
|
+
await this.carrySandboxSessionsOut(runtime, true);
|
|
27137
|
+
} catch (error61) {
|
|
27138
|
+
if (error61 instanceof EveSandboxCarryLimitError) {
|
|
27139
|
+
console.error(
|
|
27140
|
+
`The imported sandbox session carry exceeded ${EVE_HOST_CARRY_LIMITS.maxBytes} compressed bytes; failing the sandbox transfer.`
|
|
27141
|
+
);
|
|
27142
|
+
return "carry-limit-exceeded";
|
|
27143
|
+
}
|
|
27144
|
+
throw error61;
|
|
27145
|
+
}
|
|
27133
27146
|
await this.ctx.storage.put("eden.eve.host.has-imported-sandboxes", true);
|
|
27134
27147
|
await this.ctx.storage.put(key, true);
|
|
27135
27148
|
const cleanup = await runtime.exec(["rm", "-rf", stage], { stdout: "ignore", stderr: "ignore" });
|
|
@@ -12,7 +12,7 @@ interface EveQueueDeliveryClaim {
|
|
|
12
12
|
readonly messageId: string;
|
|
13
13
|
readonly attempt: number;
|
|
14
14
|
}
|
|
15
|
-
type EveSandboxImportResult = "source-export-failed" | undefined;
|
|
15
|
+
type EveSandboxImportResult = "source-export-failed" | "carry-limit-exceeded" | undefined;
|
|
16
16
|
/** The deployment's single SQLite-backed Workflow World. */
|
|
17
17
|
export declare class EdenWorldDurableObject extends DurableObject<EveHostContainerEnvironment> {
|
|
18
18
|
private readonly core;
|
package/dist/eve-host-runtime.js
CHANGED
|
@@ -122,6 +122,17 @@ export const EVE_HOST_CARRY_LIMITS = {
|
|
|
122
122
|
chunkBytes: 1024 * 1024,
|
|
123
123
|
maxBytes: 1024 * 1024 * 1024,
|
|
124
124
|
};
|
|
125
|
+
/**
|
|
126
|
+
* A required carry can never succeed while the sessions archive exceeds the
|
|
127
|
+
* carry cap, so the sandbox transfer must settle as terminally failed
|
|
128
|
+
* instead of retrying forever.
|
|
129
|
+
*/
|
|
130
|
+
class EveSandboxCarryLimitError extends Error {
|
|
131
|
+
constructor() {
|
|
132
|
+
super("The imported sandbox carry exceeds the archive limit.");
|
|
133
|
+
this.name = "EveSandboxCarryLimitError";
|
|
134
|
+
}
|
|
135
|
+
}
|
|
125
136
|
/** Snapshot attempts the alarm retries before destroying anyway so a stuck
|
|
126
137
|
* snapshot path never keeps billing alive forever. */
|
|
127
138
|
const EVE_HOST_SNAPSHOT_MAX_ATTEMPTS = 3;
|
|
@@ -181,7 +192,7 @@ export class EdenWorldDurableObject extends DurableObject {
|
|
|
181
192
|
if (message.sourceDeploymentId && message.sourceDeploymentId !== deploymentId && message.sandboxSessionId) {
|
|
182
193
|
try {
|
|
183
194
|
const result = await target.importSandboxSessions(message.sourceDeploymentId, deploymentId, message.messageId, message.sandboxSessionId);
|
|
184
|
-
if (result === "source-export-failed") {
|
|
195
|
+
if (result === "source-export-failed" || result === "carry-limit-exceeded") {
|
|
185
196
|
await settleUnstarted();
|
|
186
197
|
return { ok: false, sandboxTransferFailed: true };
|
|
187
198
|
}
|
|
@@ -288,17 +299,13 @@ export async function routeEveOutboundRequest(request, env, sourceDeploymentId,
|
|
|
288
299
|
if (env.EDEN_EVE_DEPLOYMENTS !== undefined && route === undefined) {
|
|
289
300
|
return new Response("Deployment retired; its sessions ended.", { status: 403 });
|
|
290
301
|
}
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const subtle = crypto.subtle;
|
|
299
|
-
if (expected.length === 0 || actual.length !== expected.length || !subtle.timingSafeEqual(actual, expected)) {
|
|
300
|
-
return new Response(null, { status: 403 });
|
|
301
|
-
}
|
|
302
|
+
const supplied = request.headers.get("x-eden-world-token") ?? "";
|
|
303
|
+
const encoder = new TextEncoder();
|
|
304
|
+
const expected = encoder.encode(expectedWorldToken ?? "");
|
|
305
|
+
const actual = encoder.encode(supplied);
|
|
306
|
+
const subtle = crypto.subtle;
|
|
307
|
+
if (expected.length === 0 || actual.length !== expected.length || !subtle.timingSafeEqual(actual, expected)) {
|
|
308
|
+
return new Response(null, { status: 403 });
|
|
302
309
|
}
|
|
303
310
|
const world = env.EDEN_WORLD;
|
|
304
311
|
if (world === undefined)
|
|
@@ -844,7 +851,7 @@ export class EveHostDurableContainer extends DurableObject {
|
|
|
844
851
|
if (overflowed) {
|
|
845
852
|
await discardWrittenChunks();
|
|
846
853
|
if (required)
|
|
847
|
-
throw new
|
|
854
|
+
throw new EveSandboxCarryLimitError();
|
|
848
855
|
console.error(`The Eve sandbox session carry exceeded ${EVE_HOST_CARRY_LIMITS.maxBytes} compressed bytes; keeping the previous carry.`);
|
|
849
856
|
return;
|
|
850
857
|
}
|
|
@@ -1197,7 +1204,19 @@ export class EveHostDurableContainer extends DurableObject {
|
|
|
1197
1204
|
// Persist imports before acknowledging them, including crash recovery.
|
|
1198
1205
|
// An older whole-container snapshot must not hide the refreshed carry.
|
|
1199
1206
|
await this.ctx.storage.delete(EVE_HOST_CONTAINER_SNAPSHOT_KEY);
|
|
1200
|
-
|
|
1207
|
+
try {
|
|
1208
|
+
await this.carrySandboxSessionsOut(runtime, true);
|
|
1209
|
+
}
|
|
1210
|
+
catch (error) {
|
|
1211
|
+
// An archive over the carry cap can never succeed, so the transfer
|
|
1212
|
+
// must settle as terminally failed instead of retrying forever and
|
|
1213
|
+
// pinning the deployment busy.
|
|
1214
|
+
if (error instanceof EveSandboxCarryLimitError) {
|
|
1215
|
+
console.error(`The imported sandbox session carry exceeded ${EVE_HOST_CARRY_LIMITS.maxBytes} compressed bytes; failing the sandbox transfer.`);
|
|
1216
|
+
return "carry-limit-exceeded";
|
|
1217
|
+
}
|
|
1218
|
+
throw error;
|
|
1219
|
+
}
|
|
1201
1220
|
await this.ctx.storage.put("eden.eve.host.has-imported-sandboxes", true);
|
|
1202
1221
|
await this.ctx.storage.put(key, true);
|
|
1203
1222
|
const cleanup = await runtime.exec(["rm", "-rf", stage], { stdout: "ignore", stderr: "ignore" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moinulmoin/eden-runtime-cloudflare",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"description": "Cloudflare Worker/Container host runtime for Eden's Eve deployments.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"NOTICE"
|
|
21
21
|
],
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@moinulmoin/eden-world-cloudflare": "0.11.
|
|
23
|
+
"@moinulmoin/eden-world-cloudflare": "0.11.4",
|
|
24
24
|
"@cloudflare/workers-types": "5.20261006.1"
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|