@absolutejs/sync 1.7.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.
@@ -21,18 +21,16 @@
21
21
  * For long-lived mutations choose `memoryLimit` ≥ 128 (the default 32
22
22
  * trips after a few dozen calls without pressure for GC).
23
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.
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.
36
34
  *
37
35
  * The runner is built lazily per-mutation: nothing is spawned until the
38
36
  * mutation actually runs for the first time. No engine teardown hook is
@@ -46,19 +44,17 @@ export type SandboxConfig = {
46
44
  /** Wall-clock cap per call (ms). Default 5000. */
47
45
  timeout?: number;
48
46
  /**
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.
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.
54
51
  *
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.
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.
59
55
  *
60
- * `'auto'` resolves to FFI when libJSC is reachable and Worker
61
- * otherwise; same async-actions caveat applies on the FFI path.
56
+ * Pin to `'ffi'` for hot-path read-only handlers (~300 KB cold heap
57
+ * vs ~46 MB on Worker, interrupt-driven CPU timeouts).
62
58
  */
63
59
  backend?: 'auto' | 'ffi' | 'worker';
64
60
  };
package/dist/index.js CHANGED
@@ -745,7 +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
+ backend: config.backend ?? "auto",
749
749
  memoryLimit: config.memoryLimit ?? 32
750
750
  });
751
751
  const script = await isolate.compileScript(wrap(source));
@@ -2301,5 +2301,5 @@ export {
2301
2301
  createPresenceHub
2302
2302
  };
2303
2303
 
2304
- //# debugId=DBE50EE175D625D764756E2164756E21
2304
+ //# debugId=A95C21B5786D64AE64756E2164756E21
2305
2305
  //# sourceMappingURL=index.js.map