@absolutejs/sync 1.6.0 → 1.7.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/dist/engine/index.js +2 -1
- package/dist/engine/index.js.map +3 -3
- package/dist/engine/sandbox.d.ts +36 -6
- package/dist/index.js +2 -1
- package/dist/index.js.map +3 -3
- package/package.json +3 -3
package/dist/engine/sandbox.d.ts
CHANGED
|
@@ -12,13 +12,27 @@
|
|
|
12
12
|
* - First call per mutation pays a Worker spawn + compile (~30 ms). Every
|
|
13
13
|
* subsequent call reuses the isolate and only spends ~0.5 ms creating a
|
|
14
14
|
* fresh context.
|
|
15
|
-
* - Timeout terminates the isolate (
|
|
16
|
-
*
|
|
15
|
+
* - Timeout terminates the isolate (the sandbox runner detects this and
|
|
16
|
+
* lazily re-spawns on the next call). On the FFI backend timeouts throw
|
|
17
|
+
* a TerminationException without killing the isolate; sync's runner
|
|
18
|
+
* treats both shapes the same.
|
|
17
19
|
* - Each per-call context retains some JSC metadata until the isolate's
|
|
18
|
-
* next GC sweep. Empirically ~2 MB residual per call
|
|
19
|
-
* mutations choose `memoryLimit` ≥ 128 (the default 32
|
|
20
|
-
* few dozen calls without pressure for GC).
|
|
21
|
-
*
|
|
20
|
+
* next GC sweep. Empirically ~2 MB residual per call (Worker backend).
|
|
21
|
+
* For long-lived mutations choose `memoryLimit` ≥ 128 (the default 32
|
|
22
|
+
* trips after a few dozen calls without pressure for GC).
|
|
23
|
+
*
|
|
24
|
+
* **Backend default: `'worker'`** — required so far because the `actions`
|
|
25
|
+
* machinery (insert/update/delete/change) crosses the host boundary as
|
|
26
|
+
* **async** References (they return Promises that go through the engine's
|
|
27
|
+
* writer + diff path). The isolated-jsc FFI backend only supports SYNC
|
|
28
|
+
* host fns today (per its 0.3 documented limit); calling
|
|
29
|
+
* `actions.insert(...)` from a sandboxed handler on FFI would surface as
|
|
30
|
+
* a Promise-cannot-unwrap error. Pin to Worker.
|
|
31
|
+
*
|
|
32
|
+
* Read-only sandboxed mutations that don't call `actions.*` (e.g. compute
|
|
33
|
+
* a derived value from `args` + `ctx` and `return` it) CAN opt into FFI
|
|
34
|
+
* via `sandbox: { backend: 'ffi' }` — they get the ~300 KB cold heap and
|
|
35
|
+
* interrupt-driven timeouts. Document this clearly when you do.
|
|
22
36
|
*
|
|
23
37
|
* The runner is built lazily per-mutation: nothing is spawned until the
|
|
24
38
|
* mutation actually runs for the first time. No engine teardown hook is
|
|
@@ -31,6 +45,22 @@ export type SandboxConfig = {
|
|
|
31
45
|
memoryLimit?: number;
|
|
32
46
|
/** Wall-clock cap per call (ms). Default 5000. */
|
|
33
47
|
timeout?: number;
|
|
48
|
+
/**
|
|
49
|
+
* isolated-jsc backend. Defaults to `'worker'` because the engine's
|
|
50
|
+
* `actions.insert/update/delete/change` cross the sandbox boundary as
|
|
51
|
+
* async References — and isolated-jsc's FFI backend doesn't pump
|
|
52
|
+
* async host fns (its 0.3 documented limit). The Worker backend
|
|
53
|
+
* supports both sync and async host fns.
|
|
54
|
+
*
|
|
55
|
+
* Opt into `'ffi'` only for **read-only** sandboxed handlers — ones
|
|
56
|
+
* that compute a derived value from `args` + `ctx` and return it
|
|
57
|
+
* without calling any `actions.*`. Those get the FFI cold-heap
|
|
58
|
+
* (~300 KB vs ~46 MB) + interrupt-driven timeout benefits.
|
|
59
|
+
*
|
|
60
|
+
* `'auto'` resolves to FFI when libJSC is reachable and Worker
|
|
61
|
+
* otherwise; same async-actions caveat applies on the FFI path.
|
|
62
|
+
*/
|
|
63
|
+
backend?: 'auto' | 'ffi' | 'worker';
|
|
34
64
|
};
|
|
35
65
|
/**
|
|
36
66
|
* Build a lazy runner for one mutation's sandboxed source. The first call
|
package/dist/index.js
CHANGED
|
@@ -745,6 +745,7 @@ var wrap = (source) => `
|
|
|
745
745
|
var compile = async (source, config) => {
|
|
746
746
|
const { createIsolate } = await loadIsolatedJsc();
|
|
747
747
|
const isolate = await createIsolate({
|
|
748
|
+
backend: config.backend ?? "worker",
|
|
748
749
|
memoryLimit: config.memoryLimit ?? 32
|
|
749
750
|
});
|
|
750
751
|
const script = await isolate.compileScript(wrap(source));
|
|
@@ -2300,5 +2301,5 @@ export {
|
|
|
2300
2301
|
createPresenceHub
|
|
2301
2302
|
};
|
|
2302
2303
|
|
|
2303
|
-
//# debugId=
|
|
2304
|
+
//# debugId=DBE50EE175D625D764756E2164756E21
|
|
2304
2305
|
//# sourceMappingURL=index.js.map
|