@nimbus-sh/fabric 0.8.0 → 0.10.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.
Files changed (51) hide show
  1. package/README.md +98 -11
  2. package/dist/bindings.d.ts +31 -33
  3. package/dist/bindings.d.ts.map +1 -1
  4. package/dist/bindings.js +108 -97
  5. package/dist/budgets.d.ts +102 -29
  6. package/dist/budgets.d.ts.map +1 -1
  7. package/dist/budgets.js +266 -44
  8. package/dist/do-calls.d.ts +20 -0
  9. package/dist/do-calls.d.ts.map +1 -1
  10. package/dist/do-calls.js +24 -11
  11. package/dist/fanout.d.ts +40 -32
  12. package/dist/fanout.d.ts.map +1 -1
  13. package/dist/fanout.js +48 -51
  14. package/dist/fenced-work.d.ts +3 -3
  15. package/dist/fenced-work.js +3 -3
  16. package/dist/host-wasm.d.ts +29 -0
  17. package/dist/host-wasm.d.ts.map +1 -0
  18. package/dist/host-wasm.js +31 -0
  19. package/dist/image-store.d.ts +1 -1
  20. package/dist/image-store.d.ts.map +1 -1
  21. package/dist/image-store.js +33 -1
  22. package/dist/inner-do-env.d.ts +83 -0
  23. package/dist/inner-do-env.d.ts.map +1 -0
  24. package/dist/inner-do-env.js +181 -0
  25. package/dist/isolate-pool.d.ts +40 -23
  26. package/dist/isolate-pool.d.ts.map +1 -1
  27. package/dist/isolate-pool.js +105 -55
  28. package/dist/process-fabric.d.ts +26 -11
  29. package/dist/process-fabric.d.ts.map +1 -1
  30. package/dist/process-fabric.js +44 -0
  31. package/dist/timers.d.ts +12 -0
  32. package/dist/timers.d.ts.map +1 -1
  33. package/dist/timers.js +44 -9
  34. package/dist/vendor/types.d.ts +11 -5
  35. package/dist/vendor/types.d.ts.map +1 -1
  36. package/dist/workerd-facet-host.d.ts.map +1 -1
  37. package/dist/workerd-facet-host.js +35 -30
  38. package/package.json +4 -4
  39. package/src/bindings.ts +121 -98
  40. package/src/budgets.ts +311 -53
  41. package/src/do-calls.ts +45 -11
  42. package/src/fanout.ts +62 -53
  43. package/src/fenced-work.ts +3 -3
  44. package/src/host-wasm.ts +41 -0
  45. package/src/image-store.ts +29 -2
  46. package/src/inner-do-env.ts +213 -0
  47. package/src/isolate-pool.ts +145 -75
  48. package/src/process-fabric.ts +55 -13
  49. package/src/timers.ts +45 -9
  50. package/src/vendor/types.ts +11 -5
  51. package/src/workerd-facet-host.ts +36 -31
@@ -7,9 +7,9 @@
7
7
  * running 67 npm tarball extractions (cold-start dominates). We pin
8
8
  * each job to `slot = cursor % concurrency` and use stable loader
9
9
  * IDs `nfp:${fnHash}:slot-${i}:g${generation}`, so a pool of
10
- * concurrency=4 keeps at most 4 warm isolates rather than N fresh ones.
10
+ * concurrency=N keeps at most N warm isolates rather than one per job.
11
11
  * 2. **Nimbus defaults**: compatibilityDate = CF_COMPAT_DATE (matches
12
- * the supervisor worker), compatibilityFlags = ['nodejs_compat'],
12
+ * the supervisor worker), compatibilityFlags = GUEST_COMPAT_FLAGS,
13
13
  * globalOutbound = undefined (inherit parent network so the facet can
14
14
  * reach https://registry.npmjs.org without a proxy binding).
15
15
  * 3. **Supervisor autoinjection**. The pool grabs the embedder's
@@ -23,16 +23,25 @@
23
23
  * The vendored directory contains only the upstream serialization, error,
24
24
  * and binding types used by this implementation.
25
25
  */
26
- import { CF_COMPAT_DATE } from '@nimbus-sh/core/constants.js';
26
+ import { CF_COMPAT_DATE, GUEST_COMPAT_FLAGS } from '@nimbus-sh/core/constants.js';
27
27
  import { supervisorEntrypoint } from './composition.js';
28
28
  import { supervisorBindingProps, supervisorLoaderKey } from './supervisor-props.js';
29
29
  import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
30
30
  import { serializeFunction, hashSource } from './vendor/serialize.js';
31
- import { beginLoaderFetch, recordLoaderId, withDynamicWorkerCapNamed } from './budgets.js';
31
+ import { beginLoaderFetch, beginLoaderFetchWhenFree, withDynamicWorkerCapNamed, } from './budgets.js';
32
32
  import { assertModuleMapWithinCodeLimit } from './budgets.js';
33
33
  import { recordFailure, setLastFacetId, getLastRpcFrame } from '@nimbus-sh/platform/oom-discriminator.js';
34
34
  import { classifyError } from '@nimbus-sh/platform/oom-classify.js';
35
35
  import { BindingError, ExecutionError, RetryExhaustedError, TimeoutError, } from './vendor/errors.js';
36
+ import { hostWasmIdentity } from './host-wasm.js';
37
+ /**
38
+ * How long one call waits, in all, on the Dynamic Worker ledger after
39
+ * "Dynamic worker concurrency limit exceeded" before the refusal surfaces
40
+ * (beginLoaderFetchWhenFree: let in when a hold ends or the refusal's pause
41
+ * passes). A deployed Durable Object admitted the refused batch after a 6 s
42
+ * pause; 15 s bounds a call that would never be admitted.
43
+ */
44
+ const CAP_REFUSAL_WAIT_MS = 15_000;
36
45
  /**
37
46
  * esbuild runtime helpers re-declared at the top of every generated facet
38
47
  * module. esbuild emits `__name(fn, "fn")` wrappers around every named
@@ -100,7 +109,7 @@ export function assembleLoaderWorkerModuleSource(options) {
100
109
  * Typical use:
101
110
  *
102
111
  * const pool = new IsolatePool(env, ctx, {
103
- * concurrency: 4,
112
+ * concurrency: 2,
104
113
  * tag: 'npm-install',
105
114
  * });
106
115
  * const results = await pool.map(
@@ -112,6 +121,8 @@ export class IsolatePool {
112
121
  loader;
113
122
  /** The hosting actor, as the loader budget ledger's per-DO key. */
114
123
  ctx;
124
+ /** The width this pool's dispatches are held inside (IsolatePoolOptions.claim). */
125
+ claim;
115
126
  concurrency;
116
127
  defaultTimeoutMs;
117
128
  defaultRetries;
@@ -139,11 +150,11 @@ export class IsolatePool {
139
150
  * across pool dispatches (cache-key stability).
140
151
  */
141
152
  wasmModules;
142
- /** Hash of (name + byte length + first/last bytes) of every wasm
143
- * module, folded into the loader cache key so changes invalidate
144
- * warm slots. Hashing the FULL bytes would be O(20+ MiB) per dispatch
145
- * and is unnecessary — wasm bytes are pinned at deploy time, the
146
- * length+endpoints are a strong-enough fingerprint. */
153
+ /** Hash of every constructor-time wasm module, folded into the loader
154
+ * cache key so changes invalidate warm slots: a compiled module by the
155
+ * identity its host described, bytes by name + length + first/last
156
+ * byte. Hashing the FULL bytes would be O(20+ MiB) per dispatch and is
157
+ * unnecessary — they are pinned at deploy time. */
147
158
  wasmHash;
148
159
  /**
149
160
  * Short prefix of the owning DO's id, baked into the loader.get()
@@ -175,7 +186,8 @@ export class IsolatePool {
175
186
  }
176
187
  this.loader = loader;
177
188
  this.ctx = ctx;
178
- this.concurrency = Math.max(1, opts?.concurrency ?? 4);
189
+ this.claim = opts?.claim;
190
+ this.concurrency = Math.max(1, opts?.concurrency ?? 1);
179
191
  this.defaultTimeoutMs = opts?.timeoutMs ?? 60_000;
180
192
  this.defaultRetries = Math.max(0, opts?.retries ?? 0);
181
193
  this.tag = opts?.tag ?? 'facet';
@@ -193,15 +205,34 @@ export class IsolatePool {
193
205
  // 'esbuild_wasm') are rejected loudly because the generated worker
194
206
  // would otherwise have duplicate imports. Order is preserved.
195
207
  const wasmEntries = [];
208
+ const fingerprints = [];
196
209
  const seenIds = new Set();
197
210
  if (opts?.wasmModules) {
198
- for (const [name, bytes] of Object.entries(opts.wasmModules)) {
199
- if (!(bytes instanceof ArrayBuffer)) {
211
+ for (const [name, wasm] of Object.entries(opts.wasmModules)) {
212
+ let fingerprint;
213
+ if (wasm instanceof ArrayBuffer) {
214
+ // Name + length + first/last byte: hashing 20+ MiB of wasm per
215
+ // dispatch would be wasteful, and these bytes change only with
216
+ // the deployed bundle.
217
+ const u = new Uint8Array(wasm);
218
+ const len = u.byteLength;
219
+ fingerprint = `${name}:${len}:${len > 0 ? u[0] : 0}:${len > 0 ? u[len - 1] : 0}`;
220
+ }
221
+ else if (wasm instanceof WebAssembly.Module) {
222
+ const identity = hostWasmIdentity(wasm);
223
+ if (!identity) {
224
+ throw new BindingError(`IsolatePool: wasmModules['${name}'] is a WebAssembly.Module nobody described; ` +
225
+ 'pass it through describeHostWasm (@nimbus-sh/fabric/host-wasm.js) so warm slots ' +
226
+ 'can be keyed by it and the code limit can count it.');
227
+ }
228
+ fingerprint = `${name}:host:${identity.id}:${identity.bytes}`;
229
+ }
230
+ else {
200
231
  // Reached only when a caller broke the declared option type, so the
201
- // value is whatever it really was rather than the ArrayBuffer here.
202
- const got = bytes?.constructor?.name;
203
- throw new BindingError(`IsolatePool: wasmModules['${name}'] must be ArrayBuffer ` +
204
- `(got ${got || typeof bytes}).`);
232
+ // value is whatever it really was rather than the union here.
233
+ const got = wasm?.constructor?.name;
234
+ throw new BindingError(`IsolatePool: wasmModules['${name}'] must be an ArrayBuffer or a WebAssembly.Module ` +
235
+ `(got ${got || typeof wasm}).`);
205
236
  }
206
237
  const id = name.replace(/[^A-Za-z0-9_]/g, '_').replace(/^[^A-Za-z_]/, '_');
207
238
  if (seenIds.has(id)) {
@@ -209,29 +240,12 @@ export class IsolatePool {
209
240
  `identifier-sanitisation (id='${id}'). Pick distinct module names.`);
210
241
  }
211
242
  seenIds.add(id);
212
- wasmEntries.push({ name, id, bytes });
243
+ wasmEntries.push({ name, id, wasm });
244
+ fingerprints.push(fingerprint);
213
245
  }
214
246
  }
215
247
  this.wasmModules = wasmEntries;
216
- // Fingerprint: name + length + first/last byte of each module.
217
- // Hashing 20+ MiB of wasm per dispatch would be wasteful; this
218
- // fingerprint is bytes-stable for a given deployed bundle and only
219
- // changes when the wasm itself changes (deploy-time event).
220
- if (wasmEntries.length === 0) {
221
- this.wasmHash = '0';
222
- }
223
- else {
224
- const fp = wasmEntries
225
- .map((w) => {
226
- const u = new Uint8Array(w.bytes);
227
- const len = u.byteLength;
228
- const first = len > 0 ? u[0] : 0;
229
- const last = len > 0 ? u[len - 1] : 0;
230
- return `${w.name}:${len}:${first}:${last}`;
231
- })
232
- .join('|');
233
- this.wasmHash = hashSource(fp);
234
- }
248
+ this.wasmHash = fingerprints.length === 0 ? '0' : hashSource(fingerprints.join('|'));
235
249
  const bindings = { ...(opts?.extraBindings ?? {}) };
236
250
  this.supervisorKey = 's-none';
237
251
  if (!opts?.omitSupervisor) {
@@ -311,7 +325,7 @@ export class IsolatePool {
311
325
  `id='${id}') collides with another per-call key. Pick distinct names.`);
312
326
  }
313
327
  seen.add(id);
314
- out.push({ name, id, bytes });
328
+ out.push({ name, id, wasm: bytes });
315
329
  }
316
330
  return out;
317
331
  }
@@ -347,7 +361,7 @@ export class IsolatePool {
347
361
  return '0';
348
362
  const parts = [];
349
363
  for (const w of entries) {
350
- const u = new Uint8Array(w.bytes);
364
+ const u = new Uint8Array(w.wasm);
351
365
  const len = u.byteLength;
352
366
  // djb2 over the bytes. Faster than crypto.subtle.digest at small
353
367
  // sizes, deterministic, and good enough for cache-key
@@ -374,7 +388,7 @@ export class IsolatePool {
374
388
  #buildCode(fnSource, perCallWasmEntries) {
375
389
  const workerOpts = {
376
390
  compatibilityDate: CF_COMPAT_DATE,
377
- compatibilityFlags: ['nodejs_compat'],
391
+ compatibilityFlags: [...GUEST_COMPAT_FLAGS],
378
392
  // Inherit parent network so the facet can reach registry.npmjs.org.
379
393
  globalOutbound: undefined,
380
394
  env: this.bindings,
@@ -418,7 +432,7 @@ export class IsolatePool {
418
432
  // (matters only for human-readable diffs; workerd doesn't care).
419
433
  const modules = { 'worker.js': moduleSource };
420
434
  for (const w of allWasmEntries) {
421
- modules[w.name] = { wasm: w.bytes };
435
+ modules[w.name] = { wasm: w.wasm };
422
436
  }
423
437
  assertModuleMapWithinCodeLimit(modules);
424
438
  return {
@@ -445,7 +459,7 @@ export class IsolatePool {
445
459
  * the attempt index lets a fetch invoke mint a fresh clone for retries,
446
460
  * since a Request's body is consumed once.
447
461
  */
448
- async #dispatchSlot(fnSource, fnHash, slotIndex, invoke, resilience, perCallWasm, wasAborted) {
462
+ async #dispatchSlot(fnSource, fnHash, slotIndex, invoke, resilience, perCallWasm, signal) {
449
463
  // A warm slot executes one dispatch at a time: queue behind the
450
464
  // previous owner, then record this dispatch as the new tail. The
451
465
  // tail outlives the caller's outcome: a timeout rejects the
@@ -462,7 +476,7 @@ export class IsolatePool {
462
476
  }
463
477
  const inFlight = [];
464
478
  try {
465
- return await this.#dispatchSlotOwned(fnSource, fnHash, slotIndex, invoke, resilience, perCallWasm, inFlight, wasAborted);
479
+ return await this.#dispatchSlotOwned(fnSource, fnHash, slotIndex, invoke, resilience, perCallWasm, inFlight, signal);
466
480
  }
467
481
  finally {
468
482
  // Do not delay the caller's own outcome — the tail releases when
@@ -470,7 +484,7 @@ export class IsolatePool {
470
484
  void Promise.allSettled(inFlight).then(() => release());
471
485
  }
472
486
  }
473
- async #dispatchSlotOwned(fnSource, fnHash, slotIndex, invoke, resilience, perCallWasm, inFlight, wasAborted) {
487
+ async #dispatchSlotOwned(fnSource, fnHash, slotIndex, invoke, resilience, perCallWasm, inFlight, signal) {
474
488
  // Per-call wasm fingerprint. Mixed into the cache key so two calls
475
489
  // with different bytes hit different slots (no cache poisoning).
476
490
  // For the common case (no per-call wasm) the fingerprint is '0',
@@ -492,6 +506,9 @@ export class IsolatePool {
492
506
  setLastFacetId(id, slotIndex);
493
507
  }
494
508
  catch { /* best-effort */ }
509
+ // A hold the ledger already took for the next attempt, when a refused
510
+ // call waited on it for room; otherwise the attempt begins its own.
511
+ let admitted;
495
512
  const runOnce = async () => {
496
513
  // loader.get() is synchronous from the caller's POV; the callback
497
514
  // is only invoked on cache miss. We wrap the callback tightly so a
@@ -517,16 +534,21 @@ export class IsolatePool {
517
534
  // fine and stays — it only tears down the long-lived SUPERVISOR
518
535
  // binding stub once the whole pool is done, which does NOT
519
536
  // invalidate any in-flight slot's entrypoint reference.
520
- const stub = this.loader.get(id, async () => code);
521
- recordLoaderId(this.ctx, id);
522
- const entrypoint = stub.getEntrypoint();
523
- // Direct property call, awaited by this frame — bracketed, never
524
- // wrapped. See beginLoaderFetch for the measured DO-poisoning hazard.
525
- const endFetch = beginLoaderFetch(this.ctx);
537
+ //
538
+ // The hold comes first, so it ends whatever setup throws: a retry's
539
+ // was taken when the ledger let it in.
540
+ const endFetch = admitted ?? beginLoaderFetch(this.ctx, id, this.claim);
541
+ admitted = undefined;
526
542
  try {
543
+ const stub = this.loader.get(id, async () => code);
544
+ const entrypoint = stub.getEntrypoint();
545
+ // Direct property call, awaited by this frame — bracketed, never
546
+ // wrapped. See beginLoaderFetch for the measured DO-poisoning hazard.
527
547
  return await invoke(entrypoint, attempt);
528
548
  }
529
549
  catch (err) {
550
+ // The ledger learns a limit refusal from the hold it ends.
551
+ endFetch(err);
530
552
  if (err instanceof Error) {
531
553
  throw new ExecutionError(err.message, err.stack);
532
554
  }
@@ -539,6 +561,8 @@ export class IsolatePool {
539
561
  const maxAttempts = 1 + resilience.retries;
540
562
  let lastError;
541
563
  let retriedCloneRefusal = false;
564
+ // When this call's waits for room after a limit refusal run out.
565
+ let capDeadline;
542
566
  let attempt = 0;
543
567
  while (attempt < maxAttempts) {
544
568
  try {
@@ -598,7 +622,7 @@ export class IsolatePool {
598
622
  });
599
623
  }
600
624
  catch { /* fail-soft */ }
601
- if (wasAborted?.()) {
625
+ if (signal?.aborted) {
602
626
  // The caller aborted this dispatch's Request. workerd cancelled
603
627
  // the isolate's execution context wherever it was suspended —
604
628
  // mid-syscall, mid-stream — so the interpreter's heap may hold
@@ -624,6 +648,32 @@ export class IsolatePool {
624
648
  // reverse direction. This refresh targets the stale-loader case.
625
649
  continue;
626
650
  }
651
+ if (cause === 'dynamic_worker_cap') {
652
+ // The platform refused to start this call. Nothing ran, so the
653
+ // call waits, as the platform asks, and is sent again without
654
+ // spending an attempt: on the ledger, which lets it in when a
655
+ // hold ends, or when the pause this refusal started has passed
656
+ // (the platform still counts a worker the ledger has given back:
657
+ // a fan-out's workers stay counted for a moment after their
658
+ // calls return).
659
+ capDeadline ??= Date.now() + CAP_REFUSAL_WAIT_MS;
660
+ const remainingMs = capDeadline - Date.now();
661
+ if (remainingMs > 0) {
662
+ // The deadline's timer is cleared once the wait settles: a
663
+ // pending timer keeps the hosting object from hibernating.
664
+ const deadline = new AbortController();
665
+ const timer = setTimeout(() => deadline.abort(), remainingMs);
666
+ const waitFor = signal ? AbortSignal.any([deadline.signal, signal]) : deadline.signal;
667
+ admitted = await beginLoaderFetchWhenFree(this.ctx, id, { claim: this.claim, signal: waitFor })
668
+ .catch(() => undefined)
669
+ .finally(() => clearTimeout(timer));
670
+ if (admitted)
671
+ continue;
672
+ // The caller aborted while waiting: surface its abort as above.
673
+ if (signal?.aborted)
674
+ throw lastError;
675
+ }
676
+ }
627
677
  if (attempt < maxAttempts - 1) {
628
678
  // 100 * 2^attempt, capped at 2s so retries don't compound waiting.
629
679
  const delay = Math.min(2000, 100 * Math.pow(2, attempt));
@@ -632,9 +682,9 @@ export class IsolatePool {
632
682
  attempt++;
633
683
  }
634
684
  }
635
- // On the way out only, so retries do not stack the annotation: a cap hit
636
- // carries the ledger — which ids hold slots, and that a keyed id never
637
- // gives one back — instead of the platform's bare message.
685
+ // On the way out only, so retries do not stack the annotation: a limit
686
+ // hit carries the ledger — which workers were in flight — instead of the
687
+ // platform's bare message.
638
688
  const named = withDynamicWorkerCapNamed(this.ctx, lastError);
639
689
  if (maxAttempts > 1) {
640
690
  throw new RetryExhaustedError(maxAttempts, named);
@@ -674,7 +724,7 @@ export class IsolatePool {
674
724
  // Every attempt fetches a clone: a Request's body is consumed once,
675
725
  // so the caller's original stays unspent and retries get a fresh
676
726
  // body that follows the same signal.
677
- return this.#dispatchSlot(fnSource, fnHash, 0, (entrypoint) => entrypoint.fetch(request.clone()), resilience, opts?.wasmModules, () => request.signal.aborted);
727
+ return this.#dispatchSlot(fnSource, fnHash, 0, (entrypoint) => entrypoint.fetch(request.clone()), resilience, opts?.wasmModules, request.signal);
678
728
  }
679
729
  /**
680
730
  * Run `fn` on every item in `items`, at most `concurrency` at a time,
@@ -109,6 +109,7 @@ export declare const ResidentCodeSpecSchema: z.ZodObject<{
109
109
  }, z.core.$strip>]>>;
110
110
  vfsWasmModules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
111
111
  vfsTextModules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
112
+ vfsCommonJsPacks: z.ZodOptional<z.ZodArray<z.ZodString>>;
112
113
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
113
114
  globalOutbound: z.ZodOptional<z.ZodNullable<z.ZodCustom<ServiceStub, ServiceStub>>>;
114
115
  }, z.core.$strip>;
@@ -136,6 +137,7 @@ export declare function residentBootSpecSchema<Stage extends z.ZodType>(stageSch
136
137
  }, z.core.$strip>]>>;
137
138
  vfsWasmModules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
138
139
  vfsTextModules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
140
+ vfsCommonJsPacks: z.ZodOptional<z.ZodArray<z.ZodString>>;
139
141
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
140
142
  globalOutbound: z.ZodOptional<z.ZodNullable<z.ZodCustom<ServiceStub, ServiceStub>>>;
141
143
  }, z.core.$strip>;
@@ -214,6 +216,20 @@ export interface ResidentDiskReader {
214
216
  * so the worker config can tell "embedder takes the env" from the default.
215
217
  */
216
218
  export declare function residentLoaderConfig(spec: ResidentCodeSpec, disk: ResidentDiskReader): Promise<Record<string, unknown>>;
219
+ /**
220
+ * One image holding many `{ cjs }` modules: a JSON index of `[name, length]`
221
+ * rows, a newline, and the module texts back to back. Lengths are UTF-16 code
222
+ * units, the unit the decoded text is sliced in, so decoding copies nothing:
223
+ * each module is a slice of the one string read.
224
+ *
225
+ * Encoded as its parts, in order, never joined: the image store encodes them
226
+ * straight into the image's bytes, and a joined copy would be a second full
227
+ * copy of the program's code on the coordinator.
228
+ */
229
+ export declare function encodeCommonJsPack(modules: Record<string, string>): string[];
230
+ export declare function decodeCommonJsPack(pack: string): Record<string, {
231
+ cjs: string;
232
+ }>;
217
233
  /**
218
234
  * The identity a resident process's SUPERVISOR binding is minted for. Always
219
235
  * the COORDINATOR's — a process hosted somewhere else still reads and writes
@@ -323,17 +339,14 @@ export interface ProcessImageDelivery {
323
339
  * across one. A peer-hosted process can only ever receive an image
324
340
  * through `moduleCeilingBytes` below, or by streaming it.
325
341
  *
326
- * Reachable in PRODUCTION but not from a type checker or `wrangler dev`, and
327
- * the difference is worth stating precisely because inferring one from the
328
- * other is how a wrong claim gets written down. `@cloudflare/workers-types`
329
- * 4.20260605.1 declares `get`/`abort`/`delete` and no `clone`, and the pinned
330
- * workerd is 1.20260603.1 — but the deployed runtime is Cloudflare's, not the
331
- * one wrangler bundles, and there it is present and works: enumerating the
332
- * binding on a live Worker at this repo's own compatibility_date returns
333
- * `["abort","clone","constructor","delete","get"]`, and a clone into a
334
- * destination of a DIFFERENT class had all 500 seeded files readable from the
335
- * destination's CONSTRUCTOR. No compat-date gate. So calling it is a
336
- * lockfile-and-types problem, not a platform one.
342
+ * Present in production, and since the pins moved to
343
+ * `@cloudflare/workers-types` 5.20260928.1 and workerd 1.20260926.1 also in
344
+ * the type checker and `wrangler dev` (DurableObjectFacets.clone;
345
+ * src/workerd/api/actor-state.h). Before that the types declared no `clone`
346
+ * and the pinned workerd 1.20260603.1 lacked it, while on a live Worker the
347
+ * binding enumerated `["abort","clone","constructor","delete","get"]` and a
348
+ * clone into a destination of a DIFFERENT class had all 500 seeded files
349
+ * readable from the destination's CONSTRUCTOR. No compat-date gate.
337
350
  *
338
351
  * The hazard that comes with it, measured rather than assumed: ANY `src`
339
352
  * that does not resolve to a populated facet — a typo, a name not created
@@ -384,6 +397,8 @@ export interface OneShotCodeSpec {
384
397
  mainModule: string;
385
398
  modules: Record<string, string | {
386
399
  wasm: ArrayBuffer;
400
+ } | {
401
+ cjs: string;
387
402
  }>;
388
403
  }
389
404
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"process-fabric.d.ts","sourceRoot":"","sources":["../src/process-fabric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,u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ec names it.
116
116
  */
117
117
  vfsTextModules: z.record(z.string(), z.string()).optional(),
118
+ /**
119
+ * VFS paths of generated CommonJS PACKS (encodeCommonJsPack): each image
120
+ * carries many `{ cjs }` modules, and the map gains every one of them at
121
+ * load. A node process's module cells travel this way — one module per
122
+ * file, so the guest's registry compiles only what the program requires,
123
+ * and one image per launch, so the boot spec names a path and not thousands.
124
+ */
125
+ vfsCommonJsPacks: z.array(z.string()).optional(),
118
126
  /**
119
127
  * The isolate's exact `env`: one entry per binding the embedder minted,
120
128
  * carried by reference so loopback stubs survive untouched. Defined —
@@ -229,6 +237,9 @@ export async function residentLoaderConfig(spec, disk) {
229
237
  for (const [moduleName, path] of Object.entries(spec.vfsTextModules ?? {})) {
230
238
  resolved[moduleName] = await readFacetImage(disk, path);
231
239
  }
240
+ for (const path of spec.vfsCommonJsPacks ?? []) {
241
+ Object.assign(resolved, decodeCommonJsPack(await readFacetImage(disk, path)));
242
+ }
232
243
  return {
233
244
  compatibilityDate: spec.compatibilityDate,
234
245
  compatibilityFlags: spec.compatibilityFlags,
@@ -238,6 +249,39 @@ export async function residentLoaderConfig(spec, disk) {
238
249
  ...(spec.globalOutbound !== undefined ? { globalOutbound: spec.globalOutbound } : {}),
239
250
  };
240
251
  }
252
+ /**
253
+ * One image holding many `{ cjs }` modules: a JSON index of `[name, length]`
254
+ * rows, a newline, and the module texts back to back. Lengths are UTF-16 code
255
+ * units, the unit the decoded text is sliced in, so decoding copies nothing:
256
+ * each module is a slice of the one string read.
257
+ *
258
+ * Encoded as its parts, in order, never joined: the image store encodes them
259
+ * straight into the image's bytes, and a joined copy would be a second full
260
+ * copy of the program's code on the coordinator.
261
+ */
262
+ export function encodeCommonJsPack(modules) {
263
+ const index = [];
264
+ const parts = [''];
265
+ for (const [name, text] of Object.entries(modules)) {
266
+ index.push([name, text.length]);
267
+ parts.push(text);
268
+ }
269
+ parts[0] = JSON.stringify(index) + '\n';
270
+ return parts;
271
+ }
272
+ export function decodeCommonJsPack(pack) {
273
+ const newline = pack.indexOf('\n');
274
+ const index = z.array(z.tuple([z.string(), z.number().int().nonnegative()])).parse(JSON.parse(pack.slice(0, newline)));
275
+ const modules = {};
276
+ let offset = newline + 1;
277
+ for (const [name, length] of index) {
278
+ modules[name] = { cjs: pack.slice(offset, offset + length) };
279
+ offset += length;
280
+ }
281
+ if (offset !== pack.length)
282
+ throw new Error(`Nimbus: CommonJS pack holds ${pack.length - offset} bytes its index does not name`);
283
+ return modules;
284
+ }
241
285
  /**
242
286
  * Read one content-addressed facet image and verify it against the digest its
243
287
  * path claims. Content addressing is only a guarantee if the bytes are checked
package/dist/timers.d.ts CHANGED
@@ -51,9 +51,12 @@ export declare const TIMER_REASONS_KEY = "w1_next_alarm_reasons";
51
51
  * The host instance carrying the per-instance timer chain. The field lives on
52
52
  * the embedder's DO instance so one chain serializes every timer-map
53
53
  * read-modify-write for that instance (see {@link Timers.schedule}).
54
+ * `_timerEpoch` counts {@link Timers.reset}s: a schedule or dispatch writes
55
+ * only while the epoch it was requested in is still current.
54
56
  */
55
57
  export interface TimerHost {
56
58
  _timerChain?: Promise<unknown>;
59
+ _timerEpoch?: number;
57
60
  }
58
61
  /**
59
62
  * What one timer handler may return: nothing, or a deadline this reason
@@ -113,6 +116,15 @@ export declare class Timers {
113
116
  * subsystem's in-isolate setTimeout fallback continues to work).
114
117
  */
115
118
  schedule(reason: string, whenMs: number): Promise<boolean>;
119
+ /**
120
+ * Void every timer of this instance: a schedule or dispatch already
121
+ * requested — still queued on the chain, or a dispatch whose handlers are
122
+ * running — writes no reason and arms no alarm from here on. For a
123
+ * deliberate end of the actor's state (a session destroy): call it before
124
+ * wiping storage and deleting the alarm, so nothing in flight writes the
125
+ * map back or re-arms after the wipe. Requests made after it proceed.
126
+ */
127
+ reset(): void;
116
128
  /**
117
129
  * Multi-reason timer dispatcher. Called from the DO's `alarm()` handler
118
130
  * with the embedder's handler map.
@@ -1 +1 @@
1
- {"version":3,"file":"timers.d.ts","sourceRoot":"","sources":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