eutaxy 0.17.0 → 0.17.1
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 +6 -6
- package/dist/aws.mjs +2 -2
- package/dist/bin.mjs +1 -1
- package/dist/{cli-dK6w25AU.mjs → cli-CxbXc1j2.mjs} +14 -6
- package/dist/{cli-dK6w25AU.mjs.map → cli-CxbXc1j2.mjs.map} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cloudflare.d.mts +35 -3
- package/dist/cloudflare.d.mts.map +1 -1
- package/dist/cloudflare.mjs +3 -3
- package/dist/{delivery-invariants-BXCuv43L.mjs → delivery-invariants-DO3j1mmD.mjs} +2 -2
- package/dist/{delivery-invariants-BXCuv43L.mjs.map → delivery-invariants-DO3j1mmD.mjs.map} +1 -1
- package/dist/{explore-Ci-xVeKU.d.mts → explore-CkKiOuz6.d.mts} +9 -1
- package/dist/explore-CkKiOuz6.d.mts.map +1 -0
- package/dist/index.d.mts +5 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{src-BiX530QY.mjs → src-D_hHC_-3.mjs} +250 -93
- package/dist/src-D_hHC_-3.mjs.map +1 -0
- package/dist/{src-DVqL5Rk_.mjs → src-fxWc6oGc.mjs} +18 -5
- package/dist/src-fxWc6oGc.mjs.map +1 -0
- package/dist/{workerd-b1sqOnVc.mjs → workerd-DhrzU6AZ.mjs} +351 -28
- package/dist/workerd-DhrzU6AZ.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/explore-Ci-xVeKU.d.mts.map +0 -1
- package/dist/src-BiX530QY.mjs.map +0 -1
- package/dist/src-DVqL5Rk_.mjs.map +0 -1
- package/dist/workerd-b1sqOnVc.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as writeFaults, C as toJson, F as getPath, I as invocationOf, L as redelivery, O as decisionFaults, R as canonicalJson, T as validateScenario, _ as replyOf, a as explore, b as realTick, c as decide, d as runInvocation, f as CrashSignal, g as parseBody, h as isRedirect, i as rawRun, k as readFaults, l as hostInvocation, m as findResponse, n as compareSides, p as InjectedEffectError, r as proxiedSide, t as observeCore, u as note, v as toResponse, w as defaultBounds, x as virtualEpoch, y as withoutNetwork } from "./src-
|
|
2
|
-
import { n as atLeastOncePerMessage$1 } from "./delivery-invariants-
|
|
3
|
-
import { c as checkSpecModule, s as emitRegressionTest, t as renderJson, y as describeVerdict } from "./src-
|
|
1
|
+
import { A as writeFaults, C as toJson, F as getPath, I as invocationOf, L as redelivery, O as decisionFaults, R as canonicalJson, T as validateScenario, _ as replyOf, a as explore, b as realTick, c as decide, d as runInvocation, f as CrashSignal, g as parseBody, h as isRedirect, i as rawRun, k as readFaults, l as hostInvocation, m as findResponse, n as compareSides, p as InjectedEffectError, r as proxiedSide, t as observeCore, u as note, v as toResponse, w as defaultBounds, x as virtualEpoch, y as withoutNetwork } from "./src-D_hHC_-3.mjs";
|
|
2
|
+
import { n as atLeastOncePerMessage$1 } from "./delivery-invariants-DO3j1mmD.mjs";
|
|
3
|
+
import { c as checkSpecModule, s as emitRegressionTest, t as renderJson, y as describeVerdict } from "./src-fxWc6oGc.mjs";
|
|
4
4
|
// packages/cli/src/regression.ts
|
|
5
5
|
/**
|
|
6
6
|
* Identifiers for binding names: a qualified name (`orders/DB`) becomes
|
|
@@ -687,10 +687,12 @@ async function recordRequest(request) {
|
|
|
687
687
|
/**
|
|
688
688
|
* The stub a Worker sees under a service binding's name: methods callable
|
|
689
689
|
* and awaitable, `fetch`, and the guards against what is not modelled
|
|
690
|
-
* (promise pipelining, `connect()`), with the answers supplied.
|
|
690
|
+
* (promise pipelining, `connect()`), with the answers supplied. A scripted
|
|
691
|
+
* Durable Object's stub is the same thing under its own name (`what`) with
|
|
692
|
+
* members of its own (`own`: its `id` and `name`).
|
|
691
693
|
*/
|
|
692
|
-
function serviceStub(binding, ctx, answers) {
|
|
693
|
-
const unsupported = (
|
|
694
|
+
function serviceStub(binding, ctx, answers, what = `service binding ${binding}`, own = {}) {
|
|
695
|
+
const unsupported = (reason) => refuse(ctx, `${what}: ${reason}`);
|
|
694
696
|
/**
|
|
695
697
|
* The promise a call returns. On the real stub it is an RPC promise that
|
|
696
698
|
* pipelines property reads (`stub.charge().id`); this one is not, so a read
|
|
@@ -701,7 +703,7 @@ function serviceStub(binding, ctx, answers) {
|
|
|
701
703
|
const value = Reflect.get(target, prop, target);
|
|
702
704
|
return typeof value === "function" ? value.bind(target) : value;
|
|
703
705
|
}
|
|
704
|
-
ctx.hooks.unsupported(
|
|
706
|
+
ctx.hooks.unsupported(`${what}: RPC promise pipelining (reading .${prop} on ${method}()'s promise) is not supported; await the call first`);
|
|
705
707
|
} });
|
|
706
708
|
/** One call: `stub.method(...)`, or `await stub.property` (an RPC getter). */
|
|
707
709
|
const call = (method) => {
|
|
@@ -710,12 +712,13 @@ function serviceStub(binding, ctx, answers) {
|
|
|
710
712
|
return new Proxy(invoke, { get(fn, key) {
|
|
711
713
|
if (key === "then") return awaitable;
|
|
712
714
|
if (typeof key === "symbol") return Reflect.get(fn, key);
|
|
713
|
-
ctx.hooks.unsupported(
|
|
715
|
+
ctx.hooks.unsupported(`${what}: RPC promise pipelining (reading .${method}.${key}) is not supported; await .${method} first`);
|
|
714
716
|
} });
|
|
715
717
|
};
|
|
716
718
|
const fetchThrough = async (input, init) => answers.fetch(new Request(input, init));
|
|
717
719
|
return new Proxy({}, { get(_stub, prop) {
|
|
718
720
|
if (prop === "then" || typeof prop === "symbol") return void 0;
|
|
721
|
+
if (Object.hasOwn(own, prop)) return own[prop];
|
|
719
722
|
if (prop === "fetch") return fetchThrough;
|
|
720
723
|
if (prop === "connect") return () => unsupported("connect() (a raw TCP socket) is not modelled");
|
|
721
724
|
return call(prop);
|
|
@@ -1713,18 +1716,19 @@ const calleeOfEnv = Symbol.for("eutaxy.calleeOfEnv");
|
|
|
1713
1716
|
* a database or bucket is the real one, whose calls nothing records or
|
|
1714
1717
|
* faults, and a Workflow binding is the local engine, which would run the
|
|
1715
1718
|
* class on the real clock. So the instance's `env` is put behind a view
|
|
1716
|
-
* under which every binding
|
|
1719
|
+
* under which every binding is the one the
|
|
1717
1720
|
* Worker itself sees (`worker()`, the platform's env, under the binding's
|
|
1718
1721
|
* qualified name): the call is an effect of whichever invocation the
|
|
1719
1722
|
* object's code is running as, with that binding's faults: a service's
|
|
1720
1723
|
* answered from the `service()` script or by the `callee()` hosted inside
|
|
1721
1724
|
* it, a statement or a bucket operation performed on the real store, a
|
|
1722
|
-
* Workflow instance created in the model
|
|
1725
|
+
* Workflow instance created in the model, a call into another object the
|
|
1726
|
+
* stub call it is from the Worker; and a call on a binding of a
|
|
1723
1727
|
* kind the model does not cover is refused as it is from the Worker, never
|
|
1724
1728
|
* passed on. The binding is resolved when first used, so reading it off
|
|
1725
1729
|
* `env` does nothing. Without the platform's env, or when it holds nothing
|
|
1726
1730
|
* under the name, a service call ends the run `UNSUPPORTED`, and any other
|
|
1727
|
-
* binding is the object's own, unrecorded
|
|
1731
|
+
* binding is the object's own, unrecorded. A
|
|
1728
1732
|
* class given the platform's base (`simulateConstruction`) is constructed
|
|
1729
1733
|
* with the view (`envView`) and this only tells it whose it is; for any
|
|
1730
1734
|
* other the view is in place once the constructor has returned, and the
|
|
@@ -1769,8 +1773,11 @@ function ownEnv(hooks, binding, object, instance, worker, gate) {
|
|
|
1769
1773
|
* name there) is answered from the script as it will be in the run, so a
|
|
1770
1774
|
* constructor that loads from one comes up; anything else through a
|
|
1771
1775
|
* service binding (a `fetch()`, a binding with a callee or with no script)
|
|
1772
|
-
* is refused, and so
|
|
1773
|
-
* an instance in the local engine
|
|
1776
|
+
* is refused, and so are a call on a Workflow binding, which would start
|
|
1777
|
+
* an instance in the local engine, and a call into another object, which
|
|
1778
|
+
* would run that object for real and leave it up, unless the scenario
|
|
1779
|
+
* scripts that object's namespace: then its methods answer from the
|
|
1780
|
+
* script, as a service's do. A database or a bucket is the real one
|
|
1774
1781
|
* there, as it is the reset's own: what a constructor writes to one while
|
|
1775
1782
|
* its object is reset stays unless that store's setup step comes after the
|
|
1776
1783
|
* object's. The
|
|
@@ -1787,7 +1794,7 @@ function outsideRunEnv(env, scripted = () => void 0) {
|
|
|
1787
1794
|
const member = (method) => {
|
|
1788
1795
|
const answer = async () => {
|
|
1789
1796
|
const script = scripted(qualified(name));
|
|
1790
|
-
const reply = script
|
|
1797
|
+
const reply = script?.kind !== "service" || method === "fetch" || method === "connect" ? void 0 : script.methods === void 0 ? { returns: null } : Object.hasOwn(script.methods, method) ? script.methods[method] : void 0;
|
|
1791
1798
|
if (reply === void 0) throw new Error(`eutaxy: a Durable Object's constructor called ${method} on the service binding ${name} while the scenario's objects were being reset, outside a run, and no service() script answers it there`);
|
|
1792
1799
|
if ("throws" in reply) throw scriptedError(reply.throws);
|
|
1793
1800
|
return structuredClone(reply.returns);
|
|
@@ -1815,10 +1822,43 @@ function outsideRunEnv(env, scripted = () => void 0) {
|
|
|
1815
1822
|
}
|
|
1816
1823
|
return flow;
|
|
1817
1824
|
};
|
|
1825
|
+
/**
|
|
1826
|
+
* A namespace whose stubs refuse every call: the object called would run
|
|
1827
|
+
* for real, on the real clock, and stay up into the run with what the
|
|
1828
|
+
* call left in it. Ids are the namespace's own.
|
|
1829
|
+
*/
|
|
1830
|
+
const namespaces = /* @__PURE__ */ new Map();
|
|
1831
|
+
const namespaceFor = (name, own) => {
|
|
1832
|
+
let namespace = namespaces.get(name);
|
|
1833
|
+
if (!namespace) {
|
|
1834
|
+
const refused = (method) => {
|
|
1835
|
+
const call = async () => {
|
|
1836
|
+
const script = scripted(qualified(name));
|
|
1837
|
+
const reply = script?.kind !== "scripted_object" || method === "fetch" || method === "connect" ? void 0 : script.methods === void 0 ? { returns: null } : Object.hasOwn(script.methods, method) ? script.methods[method] : void 0;
|
|
1838
|
+
if (reply === void 0) throw new Error(`eutaxy: a Durable Object's constructor called ${method} on an object of ${name} while the scenario's objects were being reset, outside a run, where a call into another object is not made${script?.kind === "scripted_object" ? " and the scriptedObject() script does not answer it" : ""}`);
|
|
1839
|
+
if ("throws" in reply) throw scriptedError(reply.throws);
|
|
1840
|
+
return structuredClone(reply.returns);
|
|
1841
|
+
};
|
|
1842
|
+
return Object.assign(call, { then: (onFulfilled, onRejected) => call().then(onFulfilled, onRejected) });
|
|
1843
|
+
};
|
|
1844
|
+
namespace = new Proxy(own, { get(target, prop) {
|
|
1845
|
+
const value = Reflect.get(target, prop, target);
|
|
1846
|
+
if (typeof value !== "function") return value;
|
|
1847
|
+
if (prop !== "get" && prop !== "getByName") return value.bind(target);
|
|
1848
|
+
return (...args) => new Proxy(Reflect.apply(value, target, args), { get(stub, key) {
|
|
1849
|
+
if (typeof key !== "string" || key === "then" || key === "id" || key === "name") return key === "then" ? void 0 : Reflect.get(stub, key, stub);
|
|
1850
|
+
return refused(key);
|
|
1851
|
+
} });
|
|
1852
|
+
} });
|
|
1853
|
+
namespaces.set(name, namespace);
|
|
1854
|
+
}
|
|
1855
|
+
return namespace;
|
|
1856
|
+
};
|
|
1818
1857
|
return new Proxy(env, { get(target, prop) {
|
|
1819
1858
|
const value = Reflect.get(target, prop, target);
|
|
1820
1859
|
if (typeof prop !== "string") return value;
|
|
1821
1860
|
if (isServiceBinding(value)) return stubFor(prop);
|
|
1861
|
+
if (isDurableObjectNamespace(value)) return namespaceFor(prop, value);
|
|
1822
1862
|
return isWorkflowBinding(value) ? flowFor(prop, value) : value;
|
|
1823
1863
|
} });
|
|
1824
1864
|
}
|
|
@@ -1881,13 +1921,41 @@ function envView(env, owner, worker, gate) {
|
|
|
1881
1921
|
}
|
|
1882
1922
|
return through;
|
|
1883
1923
|
};
|
|
1924
|
+
/**
|
|
1925
|
+
* The scenario's namespace under the object's binding `name`, or the
|
|
1926
|
+
* object's own: a call on a stub it gives is the object's call into
|
|
1927
|
+
* another object (or into itself, as the runtime allows).
|
|
1928
|
+
*/
|
|
1929
|
+
const namespaces = /* @__PURE__ */ new Map();
|
|
1930
|
+
const namespaceFor = (name, own) => {
|
|
1931
|
+
let namespace = namespaces.get(name);
|
|
1932
|
+
if (!namespace) {
|
|
1933
|
+
namespace = new Proxy(own, { get(target, prop) {
|
|
1934
|
+
const model = worker ? Reflect.get(worker(), qualified(name)) : void 0;
|
|
1935
|
+
const through = model === null || typeof model !== "object" ? target : model;
|
|
1936
|
+
const member = Reflect.get(through, prop, through);
|
|
1937
|
+
if (typeof member !== "function") return member;
|
|
1938
|
+
if (through === target || prop !== "get" && prop !== "getByName") return member.bind(through);
|
|
1939
|
+
return (...args) => {
|
|
1940
|
+
const stub = Reflect.apply(member, through, args);
|
|
1941
|
+
return new Proxy(stub, { get(to, key) {
|
|
1942
|
+
const value = Reflect.get(to, key, to);
|
|
1943
|
+
return typeof value === "function" ? calling(value, owner, gate) : value;
|
|
1944
|
+
} });
|
|
1945
|
+
};
|
|
1946
|
+
} });
|
|
1947
|
+
namespaces.set(name, namespace);
|
|
1948
|
+
}
|
|
1949
|
+
return namespace;
|
|
1950
|
+
};
|
|
1884
1951
|
const view = new Proxy(env, { get(target, prop) {
|
|
1885
1952
|
const value = Reflect.get(target, prop, target);
|
|
1886
1953
|
if (typeof prop !== "string") return value;
|
|
1887
1954
|
if (isServiceBinding(value)) return stubFor(prop);
|
|
1888
1955
|
if (isD1(value) || isR2(value)) return modelledFor(prop, value, false);
|
|
1889
1956
|
if (isWorkflowBinding(value)) return modelledFor(prop, value, true);
|
|
1890
|
-
if (isDurableObjectNamespace(value)
|
|
1957
|
+
if (isDurableObjectNamespace(value)) return namespaceFor(prop, value);
|
|
1958
|
+
if (!worker) return value;
|
|
1891
1959
|
const seen = Reflect.get(worker(), qualified(prop));
|
|
1892
1960
|
return seen === void 0 ? value : seen;
|
|
1893
1961
|
} });
|
|
@@ -2379,9 +2447,9 @@ function simulatingConstruction(on) {
|
|
|
2379
2447
|
function forgetHosts() {
|
|
2380
2448
|
hostOfId.clear();
|
|
2381
2449
|
}
|
|
2382
|
-
/** The scenario's
|
|
2450
|
+
/** The scenario's scripts by binding (a service's, a namespace's), for what a constructor calls while its object is reset. */
|
|
2383
2451
|
let scriptedOutsideRuns = () => void 0;
|
|
2384
|
-
/** Tell which service bindings the scenario being reset scripts (see `outsideRunEnv`). */
|
|
2452
|
+
/** Tell which service bindings and namespaces the scenario being reset scripts (see `outsideRunEnv`). */
|
|
2385
2453
|
function scriptsOutsideRuns(scripted) {
|
|
2386
2454
|
scriptedOutsideRuns = scripted;
|
|
2387
2455
|
}
|
|
@@ -2543,7 +2611,7 @@ async function deleteRealAlarm(storage) {
|
|
|
2543
2611
|
await (Object.hasOwn(storage, "deleteAlarm") ? proto.deleteAlarm : storage.deleteAlarm)?.call(storage);
|
|
2544
2612
|
}
|
|
2545
2613
|
/** An RPC argument as effect-log data; a Request becomes its method and URL. */
|
|
2546
|
-
function argument(value) {
|
|
2614
|
+
function argument$1(value) {
|
|
2547
2615
|
if (value instanceof Request) return {
|
|
2548
2616
|
method: value.method,
|
|
2549
2617
|
url: value.url
|
|
@@ -2567,6 +2635,34 @@ function isPlainData(value, depth = 0) {
|
|
|
2567
2635
|
if (proto !== Object.prototype && proto !== null) return false;
|
|
2568
2636
|
return Object.values(value).every((v) => isPlainData(v, depth + 1));
|
|
2569
2637
|
}
|
|
2638
|
+
/**
|
|
2639
|
+
* A call's plain result as the caller gets it: a copy, with the runtime's
|
|
2640
|
+
* own result disposed. The runtime's result keeps the call's session open
|
|
2641
|
+
* until it is disposed or collected, and an object that hands it on as its
|
|
2642
|
+
* own answer (`return stub.method()`) would keep the object it called
|
|
2643
|
+
* referenced past the run, where the next run's reset cannot evict it. A
|
|
2644
|
+
* `Response` is the caller's as it is.
|
|
2645
|
+
*/
|
|
2646
|
+
function released(result) {
|
|
2647
|
+
if (result === null || typeof result !== "object" || result instanceof Response) return result;
|
|
2648
|
+
let copy;
|
|
2649
|
+
try {
|
|
2650
|
+
copy = structuredClone(result);
|
|
2651
|
+
} catch {
|
|
2652
|
+
return result;
|
|
2653
|
+
}
|
|
2654
|
+
const dispose = disposer === void 0 ? void 0 : result[disposer];
|
|
2655
|
+
if (disposer !== void 0 && typeof dispose === "function") {
|
|
2656
|
+
Object.defineProperty(copy, disposer, {
|
|
2657
|
+
value: () => {},
|
|
2658
|
+
enumerable: false
|
|
2659
|
+
});
|
|
2660
|
+
dispose.call(result);
|
|
2661
|
+
}
|
|
2662
|
+
return copy;
|
|
2663
|
+
}
|
|
2664
|
+
/** `Symbol.dispose`, where the host has it (the compile target's library does not name it). */
|
|
2665
|
+
const disposer = Symbol.dispose;
|
|
2570
2666
|
/** An RPC result as effect-log data; a Response becomes its status. */
|
|
2571
2667
|
function summarize(result) {
|
|
2572
2668
|
if (result instanceof Response) return {
|
|
@@ -2588,10 +2684,13 @@ function proxyNamespace(real, binding, ctx, state, helpers, isReset) {
|
|
|
2588
2684
|
if (method !== void 0) hostMethod(ctx.hooks, hostOf(target, object), instance, method);
|
|
2589
2685
|
});
|
|
2590
2686
|
}
|
|
2591
|
-
/** A result passed back to the
|
|
2687
|
+
/** A result passed back to the caller; one that is not plain data cannot be followed. */
|
|
2592
2688
|
function plain(result) {
|
|
2593
|
-
if (!isPlainData(result))
|
|
2594
|
-
|
|
2689
|
+
if (!isPlainData(result)) {
|
|
2690
|
+
ctx.hooks.unsupported(`Durable Object ${binding} ${object} returned something that is not plain data (an RPC capability or an object with methods); calls on it would bypass Eutaxy`);
|
|
2691
|
+
return result;
|
|
2692
|
+
}
|
|
2693
|
+
return released(result);
|
|
2595
2694
|
}
|
|
2596
2695
|
/**
|
|
2597
2696
|
* The promise a call returns. On a real stub it is an RPC promise that
|
|
@@ -2616,7 +2715,7 @@ function proxyNamespace(real, binding, ctx, state, helpers, isReset) {
|
|
|
2616
2715
|
args,
|
|
2617
2716
|
allowed: writeFaults,
|
|
2618
2717
|
hostsEffects: true
|
|
2619
|
-
}, perform, summarize, {
|
|
2718
|
+
}, outboundGate(ctx, perform), summarize, {
|
|
2620
2719
|
host: hostOf(target, object),
|
|
2621
2720
|
onAbandon: () => state.abort(id),
|
|
2622
2721
|
mayPark: () => state.mayPark(id)
|
|
@@ -2627,7 +2726,7 @@ function proxyNamespace(real, binding, ctx, state, helpers, isReset) {
|
|
|
2627
2726
|
if (typeof prop !== "string" || prop === "id" || prop === "name") return Reflect.get(real, prop, receiver);
|
|
2628
2727
|
const call = (...args) => pipelineGuard(onObject(prop, {
|
|
2629
2728
|
object,
|
|
2630
|
-
args: args.map(argument)
|
|
2729
|
+
args: args.map(argument$1)
|
|
2631
2730
|
}, async () => {
|
|
2632
2731
|
await reach(real, prop);
|
|
2633
2732
|
const method = real[prop];
|
|
@@ -2689,6 +2788,17 @@ function proxyNamespace(real, binding, ctx, state, helpers, isReset) {
|
|
|
2689
2788
|
}
|
|
2690
2789
|
} });
|
|
2691
2790
|
}
|
|
2791
|
+
/**
|
|
2792
|
+
* The objects of a namespace that are running now, each evicted: eviction
|
|
2793
|
+
* only succeeds on a running object. For a namespace none of whose objects
|
|
2794
|
+
* should have run.
|
|
2795
|
+
*/
|
|
2796
|
+
async function evictRunning(real, helpers) {
|
|
2797
|
+
const running = [];
|
|
2798
|
+
const ids = await typed(helpers).listDurableObjectIds(real);
|
|
2799
|
+
for (const id of [...ids].sort((a, b) => a.toString() < b.toString() ? -1 : 1)) if (await typed(helpers).evictDurableObject(real.get(id)).then(() => true, () => false)) running.push(id);
|
|
2800
|
+
return running;
|
|
2801
|
+
}
|
|
2692
2802
|
/** Drop an object's instance from outside it; one that is not running has nothing to drop. */
|
|
2693
2803
|
async function evictObject(real, helpers, id) {
|
|
2694
2804
|
if (!helpers) return;
|
|
@@ -3340,6 +3450,59 @@ function service(binding, options = {}) {
|
|
|
3340
3450
|
};
|
|
3341
3451
|
}
|
|
3342
3452
|
/**
|
|
3453
|
+
* Script a Durable Object namespace: its objects' RPC methods answer from `methods` and their `fetch()`
|
|
3454
|
+
* from `fetch`, and no object of it runs. See `ScriptedObjectSetup`.
|
|
3455
|
+
*/
|
|
3456
|
+
function scriptedObject(binding, options = {}) {
|
|
3457
|
+
return {
|
|
3458
|
+
kind: "scripted_object",
|
|
3459
|
+
binding,
|
|
3460
|
+
...options.methods === void 0 ? {} : { methods: options.methods },
|
|
3461
|
+
...options.fetch === void 0 ? {} : { fetch: [...options.fetch] }
|
|
3462
|
+
};
|
|
3463
|
+
}
|
|
3464
|
+
/** The snapshot targets an invariant reads state from. */
|
|
3465
|
+
function stateTargets(invariant) {
|
|
3466
|
+
switch (invariant.kind) {
|
|
3467
|
+
case "everyRow":
|
|
3468
|
+
case "unique": return [invariant.query.target];
|
|
3469
|
+
case "implies": return [invariant.state.target];
|
|
3470
|
+
case "references": return [invariant.query.target, invariant.in.target];
|
|
3471
|
+
default: return [];
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
/**
|
|
3475
|
+
* A namespace is the real objects or a script, not both; one script per
|
|
3476
|
+
* namespace; and a script has no storage for an invariant to read.
|
|
3477
|
+
*/
|
|
3478
|
+
function validateScriptedObjectSetups(setup, invariants) {
|
|
3479
|
+
const errors = [];
|
|
3480
|
+
const real = new Set(setup.filter((s) => s.kind === "durable_object").map((s) => String(s["binding"])));
|
|
3481
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3482
|
+
for (const step of setup) {
|
|
3483
|
+
if (step.kind !== "scripted_object") continue;
|
|
3484
|
+
const binding = String(step["binding"]);
|
|
3485
|
+
if (!step["binding"]) errors.push("scriptedObject() needs a binding name");
|
|
3486
|
+
if (real.has(binding)) errors.push(`Durable Object binding ${JSON.stringify(binding)} has both a durableObject() setup and a scriptedObject() script; keep one`);
|
|
3487
|
+
if (seen.has(binding)) errors.push(`Durable Object binding ${JSON.stringify(binding)} has two scriptedObject() steps`);
|
|
3488
|
+
seen.add(binding);
|
|
3489
|
+
}
|
|
3490
|
+
for (const invariant of invariants) for (const target of stateTargets(invariant)) if (target.startsWith("DO:") && seen.has(target.slice(3))) errors.push(`invariant ${JSON.stringify(invariant.name)} reads the storage of ${target.slice(3)}, a namespace the scenario scripts: a script has no storage; select its calls with objectCall()`);
|
|
3491
|
+
return errors;
|
|
3492
|
+
}
|
|
3493
|
+
/**
|
|
3494
|
+
* Selects the calls into a Durable Object namespace that completed (real objects' or scripted ones'), one
|
|
3495
|
+
* method's or all; `object` keeps those into the object of that name.
|
|
3496
|
+
*/
|
|
3497
|
+
function objectCall(binding, method, object) {
|
|
3498
|
+
return {
|
|
3499
|
+
target: `DO:${binding}`,
|
|
3500
|
+
...method === void 0 ? {} : { op: method },
|
|
3501
|
+
kind: "result",
|
|
3502
|
+
...object === void 0 ? {} : { where: { "args.object": object } }
|
|
3503
|
+
};
|
|
3504
|
+
}
|
|
3505
|
+
/**
|
|
3343
3506
|
* Run the Worker behind a service binding for real, named by its module and its wrangler config, relative
|
|
3344
3507
|
* to the scenario; `entrypoint` names the export the binding reaches. See `CalleeSetup`.
|
|
3345
3508
|
*/
|
|
@@ -3771,6 +3934,7 @@ function defineScenario(input) {
|
|
|
3771
3934
|
...validateScenario(spec),
|
|
3772
3935
|
...validateDurableObjectSetups(spec.setup),
|
|
3773
3936
|
...validateCalleeSetups(spec.setup),
|
|
3937
|
+
...validateScriptedObjectSetups(spec.setup, spec.invariants),
|
|
3774
3938
|
...drive.kind === "http" ? validateHttpDrive(drive) : [],
|
|
3775
3939
|
...drive.kind === "rpc" ? validateRpcDrive(drive) : [],
|
|
3776
3940
|
...drive.kind === "cron" ? validateCronDrive(drive) : [],
|
|
@@ -4122,6 +4286,118 @@ async function expectHolds(spec, platform, options) {
|
|
|
4122
4286
|
const verdict = await check(spec, platform, options);
|
|
4123
4287
|
if (verdict.kind !== "BOUNDED") throw new Error(describeVerdict(verdict));
|
|
4124
4288
|
}
|
|
4289
|
+
// packages/cloudflare/src/scripted-objects.ts
|
|
4290
|
+
/**
|
|
4291
|
+
* A Durable Object namespace with its objects scripted. A caller reaches an
|
|
4292
|
+
* object through a stub of its namespace (`env.BINDING.get(id)`,
|
|
4293
|
+
* `getByName(name)`), by RPC method or by `fetch()` (Durable Objects, create
|
|
4294
|
+
* Durable Object stubs and send requests). Here no object of the namespace
|
|
4295
|
+
* is constructed or run: the scenario's `scriptedObject()` setup scripts
|
|
4296
|
+
* the replies, as `service()` scripts a Worker, and each call is one effect
|
|
4297
|
+
* on `DO:<binding>` with the object's name in its arguments and the faults
|
|
4298
|
+
* of a stub call, where `crash_before` and `error` mean the call never
|
|
4299
|
+
* reached the object, `ambiguous` that it acted and the answer was lost,
|
|
4300
|
+
* and `crash_after` that the caller died after it. Ids are the namespace's
|
|
4301
|
+
* own, so an id made here equals the one the runtime would make. The stub
|
|
4302
|
+
* is the one a scripted service has (`serviceStub`).
|
|
4303
|
+
*/
|
|
4304
|
+
/** An RPC argument as effect-log data; a Request becomes its method and URL. */
|
|
4305
|
+
function argument(value) {
|
|
4306
|
+
if (value instanceof Request) return {
|
|
4307
|
+
method: value.method,
|
|
4308
|
+
url: value.url
|
|
4309
|
+
};
|
|
4310
|
+
return toJson(value);
|
|
4311
|
+
}
|
|
4312
|
+
/** The namespace a caller sees under a scripted Durable Object binding's name. */
|
|
4313
|
+
function proxyScriptedNamespace(real, binding, ctx, script) {
|
|
4314
|
+
const target = `DO:${binding}`;
|
|
4315
|
+
const setup = `scriptedObject(${JSON.stringify(binding)})`;
|
|
4316
|
+
/** Object names by id, so the log names an object as its caller does. */
|
|
4317
|
+
const names = /* @__PURE__ */ new Map();
|
|
4318
|
+
const nameOf = (id) => names.get(id.toString()) ?? id.name ?? id.toString();
|
|
4319
|
+
const point = (op, args) => pointAt(ctx, target, op, args, writeFaults);
|
|
4320
|
+
function stubFor(id) {
|
|
4321
|
+
const object = nameOf(id);
|
|
4322
|
+
const what = `scripted Durable Object ${binding} ${object}`;
|
|
4323
|
+
const unsupported = (reason) => refuse(ctx, `${what}: ${reason}`);
|
|
4324
|
+
/** The scripted reply to a method, by name; a method the script lacks cannot be answered. */
|
|
4325
|
+
const replyTo = (method) => {
|
|
4326
|
+
if (script.methods === void 0) return { returns: null };
|
|
4327
|
+
if (!Object.hasOwn(script.methods, method)) return unsupported(`no scripted reply for method ${method}; add it to the ${setup} setup's methods`);
|
|
4328
|
+
return script.methods[method];
|
|
4329
|
+
};
|
|
4330
|
+
const answer = (method) => {
|
|
4331
|
+
const reply = replyTo(method);
|
|
4332
|
+
if ("throws" in reply) throw scriptedError(reply.throws);
|
|
4333
|
+
return structuredClone(reply.returns);
|
|
4334
|
+
};
|
|
4335
|
+
return serviceStub(binding, ctx, {
|
|
4336
|
+
call: (method, args) => ctx.hooks.effect(point(method, {
|
|
4337
|
+
object,
|
|
4338
|
+
args: args.map(argument)
|
|
4339
|
+
}), outboundGate(ctx, async () => answer(method)), toJson),
|
|
4340
|
+
property: (method) => ctx.hooks.effect(point(method, {
|
|
4341
|
+
object,
|
|
4342
|
+
property: true
|
|
4343
|
+
}), outboundGate(ctx, async () => answer(method)), toJson),
|
|
4344
|
+
async fetch(request) {
|
|
4345
|
+
const behind = outboundGate(ctx, async () => void 0);
|
|
4346
|
+
const url = new URL(request.url);
|
|
4347
|
+
const { method, headers, body } = await recordRequest(request);
|
|
4348
|
+
const reply = await ctx.hooks.effect(point("fetch", {
|
|
4349
|
+
object,
|
|
4350
|
+
url: request.url,
|
|
4351
|
+
method,
|
|
4352
|
+
headers,
|
|
4353
|
+
body
|
|
4354
|
+
}), async () => {
|
|
4355
|
+
await behind();
|
|
4356
|
+
const found = findResponse({
|
|
4357
|
+
name: binding,
|
|
4358
|
+
host: url.host,
|
|
4359
|
+
guarantees: {},
|
|
4360
|
+
...script.fetch === void 0 ? {} : { responses: script.fetch }
|
|
4361
|
+
}, method, url.pathname);
|
|
4362
|
+
if (found === void 0) return unsupported(`no scripted reply for fetch ${method} ${url.pathname}; add it to the ${setup} setup's fetch`);
|
|
4363
|
+
const reply = replyOf(found);
|
|
4364
|
+
if (reply.status === 101) return unsupported(`the scripted reply to ${method} ${url.pathname} is a 101, and a scripted object accepts no WebSocket`);
|
|
4365
|
+
if (isRedirect(reply.status) && request.redirect !== "manual") return unsupported(`the scripted reply to ${method} ${url.pathname} is a ${reply.status} redirect, which the runtime would follow; script the final reply or fetch with redirect: "manual"`);
|
|
4366
|
+
return reply;
|
|
4367
|
+
}, (r) => ({
|
|
4368
|
+
status: r.status,
|
|
4369
|
+
ok: r.status >= 200 && r.status < 300
|
|
4370
|
+
}));
|
|
4371
|
+
return toResponse(reply);
|
|
4372
|
+
}
|
|
4373
|
+
}, what, {
|
|
4374
|
+
id,
|
|
4375
|
+
name: id.name
|
|
4376
|
+
});
|
|
4377
|
+
}
|
|
4378
|
+
function idFromName(name) {
|
|
4379
|
+
const id = real.idFromName(name);
|
|
4380
|
+
names.set(id.toString(), name);
|
|
4381
|
+
return id;
|
|
4382
|
+
}
|
|
4383
|
+
return new Proxy(real, { get(namespace, prop, receiver) {
|
|
4384
|
+
switch (prop) {
|
|
4385
|
+
case "idFromName": return idFromName;
|
|
4386
|
+
case "idFromString": return (hex) => namespace.idFromString(hex);
|
|
4387
|
+
case "newUniqueId": return (options) => {
|
|
4388
|
+
if (options?.jurisdiction !== void 0) return refuse(ctx, `${binding}.newUniqueId({ jurisdiction }) is not modelled for a scripted namespace; use newUniqueId() without one`);
|
|
4389
|
+
return idFromName(`eutaxy:unique:${crypto.randomUUID()}`);
|
|
4390
|
+
};
|
|
4391
|
+
case "get": return (id) => stubFor(id);
|
|
4392
|
+
case "getByName": return (name) => stubFor(idFromName(name));
|
|
4393
|
+
case "jurisdiction": return () => refuse(ctx, `${binding}.jurisdiction() is not modelled for a scripted namespace; use the namespace itself`);
|
|
4394
|
+
default: {
|
|
4395
|
+
const value = Reflect.get(namespace, prop, receiver);
|
|
4396
|
+
return typeof value === "function" ? value.bind(namespace) : value;
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
} });
|
|
4400
|
+
}
|
|
4125
4401
|
// packages/cloudflare/src/bindings.ts
|
|
4126
4402
|
/** A D1 database: Miniflare's SQLite, reset to the scenario's schema and read back whole. */
|
|
4127
4403
|
function d1Binding(schemas) {
|
|
@@ -4255,7 +4531,7 @@ function durableObjectBinding(deps) {
|
|
|
4255
4531
|
},
|
|
4256
4532
|
async snapshot(step, real, unsupported) {
|
|
4257
4533
|
const binding = step.binding;
|
|
4258
|
-
return snapshotNamespace(namespace(binding, real), required(), stateFor(binding).names, stateFor(binding).touched, step.objects, step.sql ?? {}, stateFor(binding).seededSql, (object) => unsupported(`Durable Object ${binding} ${object} was reached without a call Eutaxy saw
|
|
4534
|
+
return snapshotNamespace(namespace(binding, real), required(), stateFor(binding).names, stateFor(binding).touched, step.objects, step.sql ?? {}, stateFor(binding).seededSql, (object) => unsupported(`Durable Object ${binding} ${object} was reached without a call Eutaxy saw: another object called it through an env the simulation does not stand behind (the env parameter its constructor kept, or a class the platform was not given)`), unsupported, deps.snapshotAll === true);
|
|
4259
4535
|
},
|
|
4260
4536
|
source: alarmSource,
|
|
4261
4537
|
closingSource: wakeSource,
|
|
@@ -4465,6 +4741,50 @@ function serviceBinding() {
|
|
|
4465
4741
|
};
|
|
4466
4742
|
}
|
|
4467
4743
|
/**
|
|
4744
|
+
* A Durable Object namespace the scenario scripts: never its objects, a
|
|
4745
|
+
* namespace whose stubs answer from the `scriptedObject` setup, each call
|
|
4746
|
+
* one effect. Nothing to reset, and no storage to snapshot: the end of the
|
|
4747
|
+
* run only looks for an object of the namespace that is running, which a
|
|
4748
|
+
* call the simulation did not stand behind reached (the real namespace's
|
|
4749
|
+
* snapshot looks for the same). A namespace without that step is not this
|
|
4750
|
+
* record's: it is the real objects'.
|
|
4751
|
+
*/
|
|
4752
|
+
function scriptedObjectBinding(helpers) {
|
|
4753
|
+
/** The namespaces the current scenario scripts. */
|
|
4754
|
+
let scripts = /* @__PURE__ */ new Map();
|
|
4755
|
+
/** Per binding, the namespace for the current run's script. */
|
|
4756
|
+
const proxies = /* @__PURE__ */ new Map();
|
|
4757
|
+
return {
|
|
4758
|
+
kind: "scripted_object",
|
|
4759
|
+
target: "DO",
|
|
4760
|
+
is: isDurableObjectNamespace,
|
|
4761
|
+
proxy(name, real, ctx) {
|
|
4762
|
+
const script = scripts.get(name);
|
|
4763
|
+
if (!script) return void 0;
|
|
4764
|
+
let p = proxies.get(name);
|
|
4765
|
+
if (!p) {
|
|
4766
|
+
p = proxyScriptedNamespace(real, name, ctx, script);
|
|
4767
|
+
proxies.set(name, p);
|
|
4768
|
+
}
|
|
4769
|
+
return p;
|
|
4770
|
+
},
|
|
4771
|
+
clear() {
|
|
4772
|
+
scripts = /* @__PURE__ */ new Map();
|
|
4773
|
+
proxies.clear();
|
|
4774
|
+
},
|
|
4775
|
+
async reset(step, real) {
|
|
4776
|
+
if (!helpers) throw new Error("scriptedObject setup needs the Cloudflare test helpers, to see that none of the namespace's objects ran: createCloudflarePlatform({ ..., durableObjects: await import(\"cloudflare:test\") })");
|
|
4777
|
+
scripts.set(step.binding, step);
|
|
4778
|
+
if (isDurableObjectNamespace(real)) await evictRunning(real, helpers);
|
|
4779
|
+
},
|
|
4780
|
+
async snapshot(step, real, unsupported) {
|
|
4781
|
+
if (!helpers || !isDurableObjectNamespace(real)) return null;
|
|
4782
|
+
for (const id of await evictRunning(real, helpers)) unsupported(`Durable Object ${step.binding} ${id.name ?? id.toString()}, of a namespace the scenario scripts, ran for real: something called it through an env the simulation does not stand behind (the env parameter a constructor kept, or a class the platform was not given)`);
|
|
4783
|
+
return null;
|
|
4784
|
+
}
|
|
4785
|
+
};
|
|
4786
|
+
}
|
|
4787
|
+
/**
|
|
4468
4788
|
* The setup steps these records own, each with its record, in setup order:
|
|
4469
4789
|
* what the platform resets and snapshots, and the differential runner
|
|
4470
4790
|
* compares. A step no record owns is left to the scenario's validation.
|
|
@@ -5242,10 +5562,11 @@ const assumptions = [
|
|
|
5242
5562
|
"message.timestamp is the virtual clock's time at delivery",
|
|
5243
5563
|
"only D1, Durable Object, R2, Workflow and scripted service bindings are proxied; a call on any other binding, from the Worker or from a Durable Object through this.env, makes the run UNSUPPORTED (reading one off env does not)",
|
|
5244
5564
|
"service bindings are scripted callees unless the scenario names a callee for them: the Worker behind a scripted binding is never called; each RPC method call or fetch() through it is one effect answered from the scenario's service() setup, where crash_before and error mean the call never reached the callee, ambiguous that it acted and the answer was lost, and crash_after that the caller died after it (developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/); Cloudflare does not retry such a call",
|
|
5565
|
+
"a Durable Object namespace with a scriptedObject() setup is scripted: none of its objects is run (one found running at the end of a run makes it UNSUPPORTED); each RPC method call or fetch() on a stub of it, from the Worker or from another object, is one effect on DO:<binding> answered from the script, the same reply whatever was called before, with the faults of a stub call (crash_before and error: it never reached the object; ambiguous: the object acted and the answer was lost; crash_after: the caller died after it) (developers.cloudflare.com/durable-objects/best-practices/create-durable-object-stubs-and-send-requests/)",
|
|
5245
5566
|
"a callee that is the scenario's own Worker, called back by a Worker it called, runs with the scenario's env under its own names; a binding named as an alias of another (the same database, the same Durable Object namespace, in two Workers' configs) is that binding: its effects and snapshot carry the other's name, and a callee's Workflow runs the callee's class with the callee's env",
|
|
5246
5567
|
"a service binding with a callee() setup runs that Worker's real code in the caller's simulation, in the same isolate, as Cloudflare runs both Workers on one thread (developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/): each RPC method call or fetch() through it is one effect hosting the callee's invocation (<caller invocation>/<binding>.<method>), which constructs the entrypoint anew with a fresh ExecutionContext and the callee's env (its bindings under <worker name>/<binding>) and answers with the return value, plain data by copy, or the Response as it is; what the callee throws reaches the caller as a new error with its name, message and serializable own properties, a built-in class as itself (developers.cloudflare.com/workers/runtime-apis/rpc/error-handling/); the callee's waitUntil work finishes before its answer crosses; crash_before means the call never reached the callee, ambiguous that it acted and the answer was lost, crash_after that the caller died after it, and a fault that crashes the callee ends its invocation and throws an Error to the caller; Cloudflare retries nothing",
|
|
5247
5568
|
"R2 buckets are Miniflare's real ones, emptied and seeded before each run and snapshotted after it; R2 is strongly consistent and the last writer wins (developers.cloudflare.com/r2/reference/consistency/); each put, delete, get, head and list is one effect, a body is read inside its get, and an object's version and upload time are stand-ins so traces repeat; multipart uploads and conditions on the upload time are not modelled",
|
|
5248
|
-
"Durable Objects are the real objects workerd runs (storage, transactions, input and output gates are the runtime's own); each stub call is one effect: crash_before or error means it never reached the object, ambiguous means the object committed and the caller lost the answer, crash_after means the caller died after it; in a concurrent run an object's own outbound I/O during a call is a turn, so another event may enter the object meanwhile (its input gate is open then), except while it holds the gate with blockConcurrencyWhile, when its effects run at once; work an object starts and does not await (a promise left running, a timer, ctx.waitUntil) goes on after its answer as the object's own invocation, DO:<binding>/<object>/after, whose effects are turns of their own and take faults by their position in it, until nothing of it can move or a crash resets the object, which ends it with the instance (work that keeps setting timers is waited for up to 100 firings without settling, then the run is UNSUPPORTED); an object that awaits a timer of its own before answering is woken by it; an effect it issued before its answer and did not await, a timer it set and real work it started (Web Crypto) are its own once the call has answered: the caller's crash does not end them and a fault in them resets the object, not the caller; in a sequential run that work runs to rest before the next event (developers.cloudflare.com/durable-objects/concepts/durable-object-lifecycle/); storage operations are not turns (the input gate holds other events during them); a call the object makes through a service binding on this.env is the scenario's: an effect of the invocation its code runs as (the call it serves, or its own work after the answer), answered from the service() script or by the callee() hosted inside it, and leaving the object once its earlier writes are durable, as behind the output gate (developers.cloudflare.com/durable-objects/api/state/, /durable-objects/concepts/durable-object-lifecycle/); a statement it runs on a D1 database or an operation on an R2 bucket through this.env is an effect of that invocation too, performed on the real store behind the same gate, and so is a call on a Workflow binding or on an instance it gave, answered by the model of the engine; a callback behind blockConcurrencyWhile that fails resets the object, as the runtime does (developers.cloudflare.com/durable-objects/api/state/#blockconcurrencywhile); objects are cleared, seeded and evicted before each run and their storage is snapshotted after it, an object a crash reset and nothing entered since being woken once inside the run first (a wake effect, its constructor's effects hosted), as its next event would wake it (developers.cloudflare.com/durable-objects/api/storage-api/)",
|
|
5569
|
+
"Durable Objects are the real objects workerd runs (storage, transactions, input and output gates are the runtime's own); each stub call is one effect: crash_before or error means it never reached the object, ambiguous means the object committed and the caller lost the answer, crash_after means the caller died after it; in a concurrent run an object's own outbound I/O during a call is a turn, so another event may enter the object meanwhile (its input gate is open then), except while it holds the gate with blockConcurrencyWhile, when its effects run at once; work an object starts and does not await (a promise left running, a timer, ctx.waitUntil) goes on after its answer as the object's own invocation, DO:<binding>/<object>/after, whose effects are turns of their own and take faults by their position in it, until nothing of it can move or a crash resets the object, which ends it with the instance (work that keeps setting timers is waited for up to 100 firings without settling, then the run is UNSUPPORTED); an object that awaits a timer of its own before answering is woken by it; an effect it issued before its answer and did not await, a timer it set and real work it started (Web Crypto) are its own once the call has answered: the caller's crash does not end them and a fault in them resets the object, not the caller; in a sequential run that work runs to rest before the next event (developers.cloudflare.com/durable-objects/concepts/durable-object-lifecycle/); storage operations are not turns (the input gate holds other events during them); a call the object makes through a service binding on this.env is the scenario's: an effect of the invocation its code runs as (the call it serves, or its own work after the answer), answered from the service() script or by the callee() hosted inside it, and leaving the object once its earlier writes are durable, as behind the output gate (developers.cloudflare.com/durable-objects/api/state/, /durable-objects/concepts/durable-object-lifecycle/); a statement it runs on a D1 database or an operation on an R2 bucket through this.env is an effect of that invocation too, performed on the real store behind the same gate, and so is a call on a Workflow binding or on an instance it gave, answered by the model of the engine; a call into another object (or itself) through this.env is the stub call it is from the Worker, hosting what the called object does: a crash inside the called object ends the invocation and resets every object the call went through, and an object reset while a call it made is in flight takes what awaited the call with it, the called object going on by itself if its code had started; a call's plain result reaches its caller as a copy; a callback behind blockConcurrencyWhile that fails resets the object, as the runtime does (developers.cloudflare.com/durable-objects/api/state/#blockconcurrencywhile); objects are cleared, seeded and evicted before each run and their storage is snapshotted after it, an object a crash reset and nothing entered since being woken once inside the run first (a wake effect, its constructor's effects hosted), as its next event would wake it (developers.cloudflare.com/durable-objects/api/storage-api/)",
|
|
5249
5570
|
"Durable Object alarms are taken over so none is scheduled on the real clock and fire in virtual time: one alarm per object, a later setAlarm replaces it, setAlarm in a transaction applies on commit, the alarm survives eviction, alarm() is one effect (crash_before: it never ran; crash_after: it ran and counts as failed; error: it threw), and a failed alarm is retried after 2 s, 4 s, 8 s ... up to six retries and maxRedeliveries, with retryCount and isRetry (developers.cloudflare.com/durable-objects/api/base/#alarm); each object's alarm fires at most alarmsPerObject times per run (default 3)",
|
|
5250
5571
|
"Workflows are a model of the engine, never the local one, running the scenario's own class: create is one effect that queues the instance; each step.do attempt is two effect points around its callback, which runs as the instance's own code (step, crash_before: the engine restarts before it; step_result, crash_after: it ran and committed but its result was not persisted, so it runs again; ambiguous at step: the attempt outlives its timeout from its start; ambiguous at step_result: it ran but counted as failed just after its work, as a timeout does); a failed attempt is retried after its delay in virtual time (defaults 5 retries, 10 s, exponential, merged field by field with a step's config), up to its limit and maxRedeliveries, except a NonRetryableError; a restart re-runs run() from the start with the persisted step and sleep results, so code outside steps repeats; a step's timeout is measured in virtual time (default 10 minutes), and an attempt that passes it is not stopped, as the engine cannot stop it either: it runs on as the late attempt while the step is retried or fails for good, its result dropped, and in a concurrent run its remaining effects land before, between or after the retry's or the recovery's (a sequential run lets it run first) (developers.cloudflare.com/workflows/build/rules-of-workflows/, /workflows/build/sleeping-and-retrying/)",
|
|
5251
5572
|
"state invariants read a snapshot of every D1 binding named in setup, taken after the last event",
|
|
@@ -5297,6 +5618,7 @@ function createCloudflarePlatform(options) {
|
|
|
5297
5618
|
}),
|
|
5298
5619
|
serviceBinding(),
|
|
5299
5620
|
d1Binding(options.schemas),
|
|
5621
|
+
scriptedObjectBinding(options.durableObjects),
|
|
5300
5622
|
durable,
|
|
5301
5623
|
r2Binding(),
|
|
5302
5624
|
workflowBinding({
|
|
@@ -5386,7 +5708,7 @@ function createCloudflarePlatform(options) {
|
|
|
5386
5708
|
await connections.clear();
|
|
5387
5709
|
for (const binding of bindings) binding.clear();
|
|
5388
5710
|
simulatingConstruction(true);
|
|
5389
|
-
scriptsOutsideRuns((name) => spec.setup.find((s) => s.kind === "service" && s["binding"] === name));
|
|
5711
|
+
scriptsOutsideRuns((name) => spec.setup.find((s) => (s.kind === "service" || s.kind === "scripted_object") && s["binding"] === canonical(name)));
|
|
5390
5712
|
for (const [binding, setup] of ownedSetups(spec.setup, bindings)) {
|
|
5391
5713
|
if (setup.binding in aliases) throw new Error(`binding ${setup.binding} is an alias of ${canonical(setup.binding)}: set it up and read it as ${canonical(setup.binding)}`);
|
|
5392
5714
|
await binding.reset(setup, env[setup.binding]);
|
|
@@ -5800,6 +6122,7 @@ async function rawSide(spec, options, stored) {
|
|
|
5800
6122
|
async function runDifferential(spec, options) {
|
|
5801
6123
|
if ((spec.drive.kind === "http" || spec.drive.kind === "rpc") && ("delaysMs" in spec.drive || "deadlineMs" in spec.drive)) throw new Error("runDifferential does not model the caller's delaysMs or deadlineMs yet");
|
|
5802
6124
|
if (spec.setup.some((s) => s.kind === "callee")) throw new Error("runDifferential keeps to the binding proxies: a scenario with a callee() has no raw side; script the service for the differential entry");
|
|
6125
|
+
if (spec.setup.some((s) => s.kind === "scripted_object")) throw new Error("runDifferential keeps to the binding proxies: a scenario with a scriptedObject() has no raw side");
|
|
5803
6126
|
const stored = storedBindings(options);
|
|
5804
6127
|
const { unsupported, ...eutaxy } = await eutaxySide(spec, options, stored);
|
|
5805
6128
|
const raw = await rawSide(spec, options, stored);
|
|
@@ -5972,6 +6295,6 @@ async function checkInWorkerd(input) {
|
|
|
5972
6295
|
}))
|
|
5973
6296
|
};
|
|
5974
6297
|
}
|
|
5975
|
-
export {
|
|
6298
|
+
export { r2Bucket as A, unique as B, fetchCall as C, objectCall as D, implies as E, rpc as F, workflowStep as G, websocket as H, rpcResponse as I, snapshotD1 as K, scriptedObject as L, r2Rows as M, references as N, queue as O, refines as P, service as R, external as S, httpResponse as T, workflow as U, webSocketReceived as V, workflowRows as W, defineScenario as _, createCloudflarePlatform as a, durableObjectTable as b, calleeEnv as c, cron as d, d1Param as f, d1Write as g, d1Schema as h, runDifferential as i, r2Op as j, queueAck as k, atLeastOncePerMessage as l, d1Rows as m, globKey as n, check as o, d1Read as p, cloudflareRegressionTest as q, specKey as r, expectHolds as s, checkInWorkerd as t, callee as u, durableObject as v, http as w, everyRow as x, durableObjectRows as y, serviceCall as z };
|
|
5976
6299
|
|
|
5977
|
-
//# sourceMappingURL=workerd-
|
|
6300
|
+
//# sourceMappingURL=workerd-DhrzU6AZ.mjs.map
|