@absolutejs/sync 1.6.0 → 1.7.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/dist/engine/index.js +2 -1
- package/dist/engine/index.js.map +3 -3
- package/dist/engine/sandbox.d.ts +32 -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,25 @@
|
|
|
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: `'auto'`** — isolated-jsc 0.4 added an async host-fn
|
|
25
|
+
* pump on the FFI backend (alternates Bun event-loop yields with JSC
|
|
26
|
+
* microtask drains, bounded by `Script.run`'s `timeout`), so the
|
|
27
|
+
* `actions.insert/update/delete/change` async References settle on FFI
|
|
28
|
+
* just like they do on Worker. `'auto'` picks FFI when libJSC is reachable
|
|
29
|
+
* (~300 KB cold heap, interrupt-driven CPU timeouts) and falls back to
|
|
30
|
+
* Worker (~46 MB cold heap, postMessage round-trips) otherwise. Pin to
|
|
31
|
+
* `'worker'` if you specifically need Web APIs (`URL`, `TextEncoder`,
|
|
32
|
+
* `WebSocket`) inside your handler — those live in the Bun-Worker
|
|
33
|
+
* environment, not the bare JSC C API.
|
|
22
34
|
*
|
|
23
35
|
* The runner is built lazily per-mutation: nothing is spawned until the
|
|
24
36
|
* mutation actually runs for the first time. No engine teardown hook is
|
|
@@ -31,6 +43,20 @@ export type SandboxConfig = {
|
|
|
31
43
|
memoryLimit?: number;
|
|
32
44
|
/** Wall-clock cap per call (ms). Default 5000. */
|
|
33
45
|
timeout?: number;
|
|
46
|
+
/**
|
|
47
|
+
* isolated-jsc backend. Defaults to `'auto'` (FFI when libJSC is
|
|
48
|
+
* reachable, Worker otherwise) since isolated-jsc 0.4 added async
|
|
49
|
+
* host-fn support on FFI — `actions.insert/update/delete/change`
|
|
50
|
+
* now settle on both backends.
|
|
51
|
+
*
|
|
52
|
+
* Pin to `'worker'` if your handler needs Web APIs (`URL`,
|
|
53
|
+
* `TextEncoder`, `WebSocket`) — those live in the Bun-Worker
|
|
54
|
+
* environment, not the bare JSC C API.
|
|
55
|
+
*
|
|
56
|
+
* Pin to `'ffi'` for hot-path read-only handlers (~300 KB cold heap
|
|
57
|
+
* vs ~46 MB on Worker, interrupt-driven CPU timeouts).
|
|
58
|
+
*/
|
|
59
|
+
backend?: 'auto' | 'ffi' | 'worker';
|
|
34
60
|
};
|
|
35
61
|
/**
|
|
36
62
|
* 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 ?? "auto",
|
|
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=A95C21B5786D64AE64756E2164756E21
|
|
2304
2305
|
//# sourceMappingURL=index.js.map
|