@moinulmoin/eden-runtime-cloudflare 0.4.1 → 0.6.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.
- package/NOTICE +0 -9
- package/dist/eden-eve-host-worker.mjs +415 -1637
- package/dist/eve-host-runtime.d.ts +82 -24
- package/dist/eve-host-runtime.js +335 -49
- package/dist/eve-host.d.ts +46 -29
- package/dist/eve-host.js +162 -114
- package/dist/index.d.ts +1 -1
- package/package.json +3 -4
package/dist/eve-host.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ export declare const EVE_HOST_DEFAULTS: {
|
|
|
2
2
|
readonly compatibilityDate: "2026-04-01";
|
|
3
3
|
readonly healthPath: "/eve/v1/health";
|
|
4
4
|
readonly internalPort: 8080;
|
|
5
|
-
readonly
|
|
6
|
-
readonly instanceType: "basic";
|
|
5
|
+
readonly instance: "standard-1";
|
|
7
6
|
readonly sleepAfter: "24h";
|
|
8
7
|
};
|
|
9
8
|
export declare const EVE_SCHEDULE_WAKE_TRIGGER_CRON = "* * * * *";
|
|
@@ -51,7 +50,7 @@ export declare function parseEveScheduleCron(cron: string): ParsedEveCron | unde
|
|
|
51
50
|
export declare function eveScheduleCronFiresWithin(cron: string, nowMs: number, leadMs?: number): boolean;
|
|
52
51
|
/** Queue and World RPC routes are private; webhooks and manifests stay forwarded. */
|
|
53
52
|
export declare function isEveWorkflowInternalRoute(pathname: string): boolean;
|
|
54
|
-
export declare const EVE_HOST_OWNED_HEADERS: readonly ["forwarded", "x-forwarded-for", "x-forwarded-host", "x-forwarded-port", "x-forwarded-proto", "x-forwarded-server", "x-forwarded-scheme", "x-real-ip", "cf-connecting-ip", "cf-visitor", "true-client-ip", "x-original-host", "x-original-proto", "x-envoy-original-host", "x-envoy-original-proto", "x-proxy-host", "x-host", "x-eve-public-origin", "x-workflow-local-base-url", "x-eden-eve-callback-base", "x-eden-eve-deployment-id", "x-eden-eve-generation-id", "x-eden-eve-
|
|
53
|
+
export declare const EVE_HOST_OWNED_HEADERS: readonly ["forwarded", "x-forwarded-for", "x-forwarded-host", "x-forwarded-port", "x-forwarded-proto", "x-forwarded-server", "x-forwarded-scheme", "x-real-ip", "cf-connecting-ip", "cf-visitor", "true-client-ip", "x-original-host", "x-original-proto", "x-envoy-original-host", "x-envoy-original-proto", "x-proxy-host", "x-host", "x-eve-public-origin", "x-workflow-local-base-url", "x-eden-eve-callback-base", "x-eden-eve-deployment-id", "x-eden-eve-generation-id", "x-eden-eve-started-deployment", "x-eden-eve-public-origin", "x-eden-eve-correlation-id", "x-eden-eve-container-name", "x-eden-eve-container-id", "x-eden-eve-runtime-revision", "x-eden-container-name", "x-eden-container-id", "cf-container-target-port"];
|
|
55
54
|
export declare const WORKER_NAME_PATTERN: RegExp;
|
|
56
55
|
export declare const IDENTIFIER_PATTERN: RegExp;
|
|
57
56
|
export type EveHostErrorCode = "HOST_ORIGIN_UNAVAILABLE" | "HOST_REQUEST_ABORTED" | "HOST_READINESS_UNPROVEN" | "HOST_TRANSPORT_UNTESTABLE" | "HOST_WEBSOCKET_UNSUPPORTED";
|
|
@@ -88,12 +87,37 @@ export interface EveHostConfigRequest extends EveHostIdentity {
|
|
|
88
87
|
/** Overrides the Container `sleepAfter` (e.g. "30s") for testing. */
|
|
89
88
|
readonly containerSleepAfter?: string;
|
|
90
89
|
readonly workflowWorld?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Durable Object state already published for this exact target. In-place
|
|
92
|
+
* updates carry the recorded binding and migration history forward
|
|
93
|
+
* verbatim: a class is only ever added once (`new_sqlite_classes` entries
|
|
94
|
+
* are append-only) and a class is never removed.
|
|
95
|
+
*/
|
|
96
|
+
readonly durableObjects?: {
|
|
97
|
+
readonly bindings?: readonly EveDurableBinding[];
|
|
98
|
+
readonly migrations?: readonly EveDurableMigration[];
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** One `durable_objects.bindings` entry as it appears in wrangler config. */
|
|
102
|
+
export interface EveDurableBinding {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
readonly class_name: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* One `migrations` entry as it appears in wrangler config. Entries are
|
|
108
|
+
* compared by tag and carried forward verbatim across in-place updates;
|
|
109
|
+
* `new_sqlite_classes` declares a class.
|
|
110
|
+
*/
|
|
111
|
+
export interface EveDurableMigration {
|
|
112
|
+
readonly tag: string;
|
|
113
|
+
readonly new_sqlite_classes?: readonly string[];
|
|
91
114
|
}
|
|
92
115
|
export interface EveHostWranglerConfig {
|
|
93
116
|
readonly account_id?: string;
|
|
94
117
|
readonly name: string;
|
|
95
118
|
readonly main: string;
|
|
96
119
|
readonly compatibility_date: string;
|
|
120
|
+
readonly compatibility_flags: readonly ["enable_ctx_exports"];
|
|
97
121
|
readonly workers_dev: true;
|
|
98
122
|
readonly vars: {
|
|
99
123
|
readonly EVE_PUBLIC_ORIGIN: string;
|
|
@@ -113,24 +137,18 @@ export interface EveHostWranglerConfig {
|
|
|
113
137
|
{
|
|
114
138
|
readonly name: string;
|
|
115
139
|
readonly class_name: string;
|
|
116
|
-
readonly
|
|
117
|
-
readonly
|
|
118
|
-
|
|
119
|
-
|
|
140
|
+
readonly scheduling_policy: "durable_object";
|
|
141
|
+
readonly images: {
|
|
142
|
+
readonly eve: {
|
|
143
|
+
readonly image: string;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
120
146
|
}
|
|
121
147
|
];
|
|
122
148
|
readonly durable_objects: {
|
|
123
|
-
readonly bindings: readonly
|
|
124
|
-
readonly name: string;
|
|
125
|
-
readonly class_name: string;
|
|
126
|
-
}[];
|
|
149
|
+
readonly bindings: readonly EveDurableBinding[];
|
|
127
150
|
};
|
|
128
|
-
readonly migrations: readonly [
|
|
129
|
-
{
|
|
130
|
-
readonly tag: "v1";
|
|
131
|
-
readonly new_sqlite_classes: readonly string[];
|
|
132
|
-
}
|
|
133
|
-
];
|
|
151
|
+
readonly migrations: readonly EveDurableMigration[];
|
|
134
152
|
}
|
|
135
153
|
export interface EveHostContainerConfig {
|
|
136
154
|
readonly applicationName: string;
|
|
@@ -173,7 +191,7 @@ export interface EveHostProxyOptions extends EveHostForwardingMetadata {
|
|
|
173
191
|
}
|
|
174
192
|
export declare function createEveHostProxy(options: EveHostProxyOptions): (request: Request) => Promise<Response>;
|
|
175
193
|
export interface EveHostLifecycleEvent {
|
|
176
|
-
readonly type: "start_requested" | "started" | "health_ready" | "stopped" | "errored" | "replaced";
|
|
194
|
+
readonly type: "start_requested" | "started" | "health_ready" | "stopped" | "errored" | "image_mismatch" | "replaced";
|
|
177
195
|
readonly at: number;
|
|
178
196
|
readonly safeStatus?: string;
|
|
179
197
|
}
|
|
@@ -202,20 +220,19 @@ export interface EveHostReadinessEvidence {
|
|
|
202
220
|
readonly checkedAt: string;
|
|
203
221
|
}
|
|
204
222
|
export interface EveHostReadinessOptions {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
};
|
|
213
|
-
}) => Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Ensures the Container is started (`ctx.container.start` when not
|
|
225
|
+
* running). Transient failures — scheduling-capacity errors surface only
|
|
226
|
+
* through `monitor()`/`start()` — are retried inside the gate's overall
|
|
227
|
+
* readiness deadline.
|
|
228
|
+
*/
|
|
229
|
+
readonly start: (signal: AbortSignal) => Promise<void>;
|
|
214
230
|
readonly healthFetch: (request: Request) => Promise<Response>;
|
|
215
231
|
readonly healthPath?: "/eve/v1/health";
|
|
216
232
|
readonly port?: 8080;
|
|
217
|
-
|
|
218
|
-
readonly
|
|
233
|
+
/** Total deadline covering start retries and the health poll. */
|
|
234
|
+
readonly readinessTimeoutMs?: number;
|
|
235
|
+
/** Per-probe cap on a single health request. */
|
|
219
236
|
readonly healthTimeoutMs?: number;
|
|
220
237
|
readonly waitIntervalMs?: number;
|
|
221
238
|
}
|
package/dist/eve-host.js
CHANGED
|
@@ -2,8 +2,7 @@ export const EVE_HOST_DEFAULTS = {
|
|
|
2
2
|
compatibilityDate: "2026-04-01",
|
|
3
3
|
healthPath: "/eve/v1/health",
|
|
4
4
|
internalPort: 8080,
|
|
5
|
-
|
|
6
|
-
instanceType: "basic",
|
|
5
|
+
instance: "standard-1",
|
|
7
6
|
sleepAfter: "24h",
|
|
8
7
|
};
|
|
9
8
|
export const EVE_SCHEDULE_WAKE_TRIGGER_CRON = "* * * * *";
|
|
@@ -189,13 +188,12 @@ export const EVE_HOST_OWNED_HEADERS = [
|
|
|
189
188
|
"x-eden-eve-callback-base",
|
|
190
189
|
"x-eden-eve-deployment-id",
|
|
191
190
|
"x-eden-eve-generation-id",
|
|
191
|
+
"x-eden-eve-started-deployment",
|
|
192
192
|
"x-eden-eve-public-origin",
|
|
193
193
|
"x-eden-eve-correlation-id",
|
|
194
194
|
"x-eden-eve-container-name",
|
|
195
195
|
"x-eden-eve-container-id",
|
|
196
196
|
"x-eden-eve-runtime-revision",
|
|
197
|
-
"x-eden-deployment-id",
|
|
198
|
-
"x-eden-generation-id",
|
|
199
197
|
"x-eden-container-name",
|
|
200
198
|
"x-eden-container-id",
|
|
201
199
|
"cf-container-target-port",
|
|
@@ -300,13 +298,63 @@ export function createEveHostConfig(request) {
|
|
|
300
298
|
const container = {
|
|
301
299
|
name: request.containerApplicationName,
|
|
302
300
|
class_name: request.containerClassName,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
? {}
|
|
306
|
-
: { image_build_context: request.containerImageBuildContext }),
|
|
307
|
-
max_instances: EVE_HOST_DEFAULTS.maxInstances,
|
|
308
|
-
instance_type: EVE_HOST_DEFAULTS.instanceType,
|
|
301
|
+
scheduling_policy: "durable_object",
|
|
302
|
+
images: { eve: { image: request.containerImage } },
|
|
309
303
|
};
|
|
304
|
+
const worldCloudflare = request.workflowWorld === "@moinulmoin/eden-world-cloudflare";
|
|
305
|
+
const priorMigrations = [];
|
|
306
|
+
for (const migration of request.durableObjects?.migrations ?? []) {
|
|
307
|
+
const validClassList = (value) => Array.isArray(value) &&
|
|
308
|
+
value.every((className) => typeof className === "string" &&
|
|
309
|
+
IDENTIFIER_PATTERN.test(className));
|
|
310
|
+
if (typeof migration.tag !== "string" ||
|
|
311
|
+
migration.tag.length === 0 ||
|
|
312
|
+
!validClassList(migration.new_sqlite_classes)) {
|
|
313
|
+
throw new EveHostError("HOST_READINESS_UNPROVEN", "The recorded Durable Object migration history is not safely reusable; refusing to drop or rewrite prior tags.");
|
|
314
|
+
}
|
|
315
|
+
priorMigrations.push(migration);
|
|
316
|
+
}
|
|
317
|
+
const bindings = [
|
|
318
|
+
{
|
|
319
|
+
name: request.containerBindingName,
|
|
320
|
+
class_name: request.containerClassName,
|
|
321
|
+
},
|
|
322
|
+
...(worldCloudflare
|
|
323
|
+
? [{ name: "EDEN_WORLD", class_name: "EdenWorldDurableObject" }]
|
|
324
|
+
: []),
|
|
325
|
+
];
|
|
326
|
+
for (const priorBinding of request.durableObjects?.bindings ?? []) {
|
|
327
|
+
if (typeof priorBinding.name !== "string" ||
|
|
328
|
+
!IDENTIFIER_PATTERN.test(priorBinding.name) ||
|
|
329
|
+
typeof priorBinding.class_name !== "string" ||
|
|
330
|
+
!IDENTIFIER_PATTERN.test(priorBinding.class_name)) {
|
|
331
|
+
throw new EveHostError("HOST_READINESS_UNPROVEN", "The recorded Durable Object bindings are not safely reusable; refusing to drop or rewrite prior bindings.");
|
|
332
|
+
}
|
|
333
|
+
// Only classes the generated Worker can export are carried; the World
|
|
334
|
+
// Durable Object's binding is retained across World switches so its class
|
|
335
|
+
// (and SQLite data) is never dropped or left without a namespace.
|
|
336
|
+
if (priorBinding.class_name === "EdenWorldDurableObject" &&
|
|
337
|
+
bindings.every((binding) => binding.name !== priorBinding.name)) {
|
|
338
|
+
bindings.push(priorBinding);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const declaredClasses = new Set(priorMigrations.flatMap((migration) => migration.new_sqlite_classes ?? []));
|
|
342
|
+
const newClasses = [
|
|
343
|
+
...new Set(bindings.map((binding) => binding.class_name)),
|
|
344
|
+
].filter((className) => !declaredClasses.has(className));
|
|
345
|
+
const migrations = [...priorMigrations];
|
|
346
|
+
if (newClasses.length > 0) {
|
|
347
|
+
let sequence = priorMigrations.reduce((highest, migration) => /^v(\d+)$/u.test(migration.tag)
|
|
348
|
+
? Math.max(highest, Number(migration.tag.slice(1)))
|
|
349
|
+
: highest, 0);
|
|
350
|
+
const usedTags = new Set(priorMigrations.map((migration) => migration.tag));
|
|
351
|
+
let tag = `v${sequence + 1}`;
|
|
352
|
+
while (usedTags.has(tag)) {
|
|
353
|
+
sequence += 1;
|
|
354
|
+
tag = `v${sequence + 1}`;
|
|
355
|
+
}
|
|
356
|
+
migrations.push({ tag, new_sqlite_classes: newClasses });
|
|
357
|
+
}
|
|
310
358
|
return {
|
|
311
359
|
worker: {
|
|
312
360
|
...(request.accountId === undefined
|
|
@@ -315,6 +363,7 @@ export function createEveHostConfig(request) {
|
|
|
315
363
|
name: request.workerName,
|
|
316
364
|
main: "worker.ts",
|
|
317
365
|
compatibility_date: EVE_HOST_DEFAULTS.compatibilityDate,
|
|
366
|
+
compatibility_flags: ["enable_ctx_exports"],
|
|
318
367
|
workers_dev: true,
|
|
319
368
|
vars: {
|
|
320
369
|
EVE_PUBLIC_ORIGIN: request.stableWorkersDevOrigin,
|
|
@@ -337,28 +386,8 @@ export function createEveHostConfig(request) {
|
|
|
337
386
|
? {}
|
|
338
387
|
: { triggers: { crons: [EVE_SCHEDULE_WAKE_TRIGGER_CRON] } }),
|
|
339
388
|
containers: [container],
|
|
340
|
-
durable_objects: {
|
|
341
|
-
|
|
342
|
-
{
|
|
343
|
-
name: request.containerBindingName,
|
|
344
|
-
class_name: request.containerClassName,
|
|
345
|
-
},
|
|
346
|
-
...(request.workflowWorld === "@moinulmoin/eden-world-cloudflare"
|
|
347
|
-
? [{ name: "EDEN_WORLD", class_name: "EdenWorldDurableObject" }]
|
|
348
|
-
: []),
|
|
349
|
-
],
|
|
350
|
-
},
|
|
351
|
-
migrations: [
|
|
352
|
-
{
|
|
353
|
-
tag: "v1",
|
|
354
|
-
new_sqlite_classes: [
|
|
355
|
-
request.containerClassName,
|
|
356
|
-
...(request.workflowWorld === "@moinulmoin/eden-world-cloudflare"
|
|
357
|
-
? ["EdenWorldDurableObject"]
|
|
358
|
-
: []),
|
|
359
|
-
],
|
|
360
|
-
},
|
|
361
|
-
],
|
|
389
|
+
durable_objects: { bindings },
|
|
390
|
+
migrations,
|
|
362
391
|
},
|
|
363
392
|
container: {
|
|
364
393
|
applicationName: request.containerApplicationName,
|
|
@@ -394,17 +423,19 @@ export function generateEveHostWorkerSource(request) {
|
|
|
394
423
|
? {}
|
|
395
424
|
: { schedules: request.config.container.schedules }),
|
|
396
425
|
};
|
|
426
|
+
const exportContainerClass = request.config.container.className === "EveHostDurableContainer"
|
|
427
|
+
? "export { EveHostDurableContainer };"
|
|
428
|
+
: `export { EveHostDurableContainer as ${request.config.container.className} };`;
|
|
397
429
|
return [
|
|
398
|
-
`import {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
: `export { ContainerProxy, EveHostContainer as ${request.config.container.className} };`,
|
|
430
|
+
`import { EdenWorldDurableObject, EveHostDurableContainer, EveHostLoopback, createEveHostWorker } from ${JSON.stringify(moduleSpecifier)};`,
|
|
431
|
+
`export { EveHostLoopback };`,
|
|
432
|
+
exportContainerClass,
|
|
402
433
|
"",
|
|
403
|
-
...(request.config.worker.vars.EDEN_EVE_WORLD_CLOUDFLARE
|
|
404
|
-
|
|
434
|
+
...(request.config.worker.vars.EDEN_EVE_WORLD_CLOUDFLARE === true ||
|
|
435
|
+
request.config.worker.durable_objects.bindings.some((binding) => binding.class_name === "EdenWorldDurableObject") ||
|
|
436
|
+
request.config.worker.migrations.some((migration) => (migration.new_sqlite_classes ?? []).includes("EdenWorldDurableObject"))
|
|
437
|
+
? ["export { EdenWorldDurableObject };"]
|
|
405
438
|
: []),
|
|
406
|
-
`EveHostContainer.outboundByHost = { ${JSON.stringify(new URL(request.config.container.publicOrigin).hostname)}: routeEveOutboundRequest };`,
|
|
407
|
-
"",
|
|
408
439
|
`export default createEveHostWorker(${JSON.stringify(workerOptions)});`,
|
|
409
440
|
"",
|
|
410
441
|
].join("\n");
|
|
@@ -566,8 +597,7 @@ function raceWithAbort(promise, signal) {
|
|
|
566
597
|
export function createEveReadinessGate(options) {
|
|
567
598
|
const port = options.port ?? EVE_HOST_DEFAULTS.internalPort;
|
|
568
599
|
const healthPath = options.healthPath ?? EVE_HOST_DEFAULTS.healthPath;
|
|
569
|
-
const
|
|
570
|
-
const portReadyTimeoutMs = options.portReadyTimeoutMs ?? 30_000;
|
|
600
|
+
const readinessTimeoutMs = options.readinessTimeoutMs ?? 150_000;
|
|
571
601
|
const healthTimeoutMs = options.healthTimeoutMs ?? 10_000;
|
|
572
602
|
const waitIntervalMs = options.waitIntervalMs ?? 300;
|
|
573
603
|
let evidence;
|
|
@@ -575,83 +605,101 @@ export function createEveReadinessGate(options) {
|
|
|
575
605
|
let inFlightController;
|
|
576
606
|
let generation = 0;
|
|
577
607
|
const run = async (signal) => {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
608
|
+
const deadline = Date.now() + readinessTimeoutMs;
|
|
609
|
+
let lastFailure;
|
|
610
|
+
const sleep = () => new Promise((resolve, reject) => {
|
|
611
|
+
const timer = setTimeout(resolve, waitIntervalMs);
|
|
612
|
+
signal.addEventListener("abort", () => {
|
|
613
|
+
clearTimeout(timer);
|
|
614
|
+
reject(new EveHostError("HOST_REQUEST_ABORTED", "The client request was cancelled before Eve became ready."));
|
|
615
|
+
}, { once: true });
|
|
616
|
+
});
|
|
617
|
+
const probe = async () => {
|
|
618
|
+
const healthController = new AbortController();
|
|
619
|
+
let rejectHealthTimeout;
|
|
620
|
+
const abortHealth = () => {
|
|
621
|
+
healthController.abort();
|
|
622
|
+
rejectHealthTimeout?.(new EveHostError("HOST_REQUEST_ABORTED", "The client request was cancelled before Eve became ready."));
|
|
623
|
+
};
|
|
624
|
+
signal.addEventListener("abort", abortHealth, { once: true });
|
|
625
|
+
const healthTimeoutResult = new Promise((_resolve, reject) => {
|
|
626
|
+
rejectHealthTimeout = reject;
|
|
587
627
|
});
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
628
|
+
const healthTimeout = setTimeout(() => {
|
|
629
|
+
healthController.abort();
|
|
630
|
+
rejectHealthTimeout?.(new EveHostError("HOST_READINESS_UNPROVEN", "The bounded Eve health probe timed out."));
|
|
631
|
+
}, healthTimeoutMs);
|
|
632
|
+
let response;
|
|
633
|
+
try {
|
|
634
|
+
const healthRequest = new Request(`http://localhost${healthPath}`, {
|
|
635
|
+
method: "GET",
|
|
636
|
+
signal: healthController.signal,
|
|
637
|
+
});
|
|
638
|
+
const healthResult = options.healthFetch(healthRequest);
|
|
639
|
+
response = await Promise.race([healthResult, healthTimeoutResult]);
|
|
592
640
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
641
|
+
catch {
|
|
642
|
+
// The port is not open yet (or the probe was aborted); poll again
|
|
643
|
+
// until the overall readiness deadline.
|
|
644
|
+
return undefined;
|
|
645
|
+
}
|
|
646
|
+
finally {
|
|
647
|
+
clearTimeout(healthTimeout);
|
|
648
|
+
signal.removeEventListener("abort", abortHealth);
|
|
649
|
+
}
|
|
650
|
+
if (response.status !== 200) {
|
|
651
|
+
await response.arrayBuffer().catch(() => undefined);
|
|
652
|
+
lastFailure = new EveHostError("HOST_READINESS_UNPROVEN", "The Eve health route did not return the expected successful status.");
|
|
653
|
+
return undefined;
|
|
654
|
+
}
|
|
655
|
+
if (!(response.headers.get("content-type") ?? "")
|
|
656
|
+
.toLowerCase()
|
|
657
|
+
.startsWith("application/json")) {
|
|
658
|
+
await response.arrayBuffer().catch(() => undefined);
|
|
659
|
+
lastFailure = new EveHostError("HOST_READINESS_UNPROVEN", "The Eve health route did not return the expected JSON contract.");
|
|
660
|
+
return undefined;
|
|
661
|
+
}
|
|
662
|
+
let body;
|
|
663
|
+
try {
|
|
664
|
+
body = await response.json();
|
|
665
|
+
}
|
|
666
|
+
catch {
|
|
667
|
+
lastFailure = new EveHostError("HOST_READINESS_UNPROVEN", "The Eve health route did not return a valid ready response.");
|
|
668
|
+
return undefined;
|
|
669
|
+
}
|
|
670
|
+
if (!responseBodyIsReady(body)) {
|
|
671
|
+
lastFailure = new EveHostError("HOST_READINESS_UNPROVEN", "The Eve health route is reachable but has not reported ready.");
|
|
672
|
+
return undefined;
|
|
673
|
+
}
|
|
674
|
+
return {
|
|
675
|
+
healthPath,
|
|
676
|
+
healthStatus: "ready",
|
|
677
|
+
healthVerified: true,
|
|
678
|
+
port,
|
|
679
|
+
checkedAt: new Date().toISOString(),
|
|
680
|
+
};
|
|
600
681
|
};
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const healthTimeout = setTimeout(() => {
|
|
606
|
-
healthController.abort();
|
|
607
|
-
rejectHealthTimeout?.(new EveHostError("HOST_READINESS_UNPROVEN", "The bounded Eve health probe timed out."));
|
|
608
|
-
}, healthTimeoutMs);
|
|
609
|
-
let response;
|
|
610
|
-
try {
|
|
611
|
-
const healthRequest = new Request(`http://localhost${healthPath}`, {
|
|
612
|
-
method: "GET",
|
|
613
|
-
signal: healthController.signal,
|
|
614
|
-
});
|
|
615
|
-
const healthResult = options.healthFetch(healthRequest);
|
|
616
|
-
response = await Promise.race([healthResult, healthTimeoutResult]);
|
|
617
|
-
}
|
|
618
|
-
catch {
|
|
619
|
-
if (signal.aborted) {
|
|
620
|
-
throw new EveHostError("HOST_REQUEST_ABORTED", "The client request was cancelled before Eve became ready.");
|
|
682
|
+
for (;;) {
|
|
683
|
+
throwIfAborted(signal);
|
|
684
|
+
try {
|
|
685
|
+
await options.start(signal);
|
|
621
686
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
.
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
let body;
|
|
639
|
-
try {
|
|
640
|
-
body = await response.json();
|
|
641
|
-
}
|
|
642
|
-
catch {
|
|
643
|
-
throw new EveHostError("HOST_READINESS_UNPROVEN", "The Eve health route did not return a valid ready response.");
|
|
644
|
-
}
|
|
645
|
-
if (!responseBodyIsReady(body)) {
|
|
646
|
-
throw new EveHostError("HOST_READINESS_UNPROVEN", "The Eve health route is reachable but has not reported ready.");
|
|
687
|
+
catch (error) {
|
|
688
|
+
throwIfAborted(signal);
|
|
689
|
+
// Transient scheduling/capacity failures surface through start() or
|
|
690
|
+
// monitor(); retry until the readiness deadline.
|
|
691
|
+
lastFailure = error instanceof EveHostError
|
|
692
|
+
? error
|
|
693
|
+
: new EveHostError("HOST_READINESS_UNPROVEN", "The Eve Container could not be scheduled for start.");
|
|
694
|
+
}
|
|
695
|
+
const result = await probe();
|
|
696
|
+
if (result !== undefined)
|
|
697
|
+
return result;
|
|
698
|
+
if (Date.now() >= deadline) {
|
|
699
|
+
throw lastFailure ?? new EveHostError("HOST_READINESS_UNPROVEN", "The Eve Container did not reach its readiness deadline.");
|
|
700
|
+
}
|
|
701
|
+
await sleep();
|
|
647
702
|
}
|
|
648
|
-
return {
|
|
649
|
-
healthPath,
|
|
650
|
-
healthStatus: "ready",
|
|
651
|
-
healthVerified: true,
|
|
652
|
-
port,
|
|
653
|
-
checkedAt: new Date().toISOString(),
|
|
654
|
-
};
|
|
655
703
|
};
|
|
656
704
|
const gate = ((signal) => {
|
|
657
705
|
throwIfAborted(signal);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { EVE_HOST_DEFAULTS, EVE_SCHEDULE_WAKE_LEAD_MS, EVE_SCHEDULE_WAKE_TRIGGER_CRON, eveScheduleCronFiresWithin, expandEveCronField, parseEveScheduleCron, EVE_HOST_OWNED_HEADERS, EveHostError, createEveHostConfig, createEveHostLifecycleObserver, createEveHostProxy, createEveReadinessGate, createTrustedEveRequest, generateEveHostWorkerSource, resolveStableWorkersDevOrigin, } from "./eve-host.js";
|
|
2
|
-
export type { EveContainerTransport, EveHostConfig, EveHostConfigRequest, EveHostContainerConfig, EveHostContainerEnvironment, EveHostErrorCode, EveScheduleCronEntry, EveHostForwardingMetadata, EveHostIdentity, EveHostLifecycleEvent, EveHostLifecycleObserver, EveHostProxyOptions, EveHostReadinessEvidence, EveHostReadinessOptions, EveReadinessGate, EveHostWranglerConfig, EveGeneratedWorkerSourceRequest, StableWorkersDevOriginRequest, } from "./eve-host.js";
|
|
2
|
+
export type { EveDurableBinding, EveDurableMigration, EveContainerTransport, EveHostConfig, EveHostConfigRequest, EveHostContainerConfig, EveHostContainerEnvironment, EveHostErrorCode, EveScheduleCronEntry, EveHostForwardingMetadata, EveHostIdentity, EveHostLifecycleEvent, EveHostLifecycleObserver, EveHostProxyOptions, EveHostReadinessEvidence, EveHostReadinessOptions, EveReadinessGate, EveHostWranglerConfig, EveGeneratedWorkerSourceRequest, StableWorkersDevOriginRequest, } from "./eve-host.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moinulmoin/eden-runtime-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Cloudflare Worker/Container host runtime for Eden's Eve deployments.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
"NOTICE"
|
|
21
21
|
],
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@cloudflare
|
|
24
|
-
"@
|
|
25
|
-
"@cloudflare/workers-types": "5.20260810.1"
|
|
23
|
+
"@moinulmoin/eden-world-cloudflare": "0.6.0",
|
|
24
|
+
"@cloudflare/workers-types": "5.20261006.1"
|
|
26
25
|
},
|
|
27
26
|
"repository": {
|
|
28
27
|
"type": "git",
|