@nimbus-sh/worker 0.2.2 → 0.3.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/README.md +5 -2
- package/dist/_shared/session-router.d.ts +8 -0
- package/dist/_shared/session-router.d.ts.map +1 -1
- package/dist/_shared/session-router.js +8 -0
- package/dist/facets/cirrus-real.js +1 -1
- package/dist/facets/manager.d.ts +42 -104
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +126 -283
- package/dist/facets/opencode-staging.d.ts +1 -1
- package/dist/facets/opencode-staging.d.ts.map +1 -1
- package/dist/facets/opencode-staging.js +4 -0
- package/dist/facets/vite-dev-server.d.ts +2 -2
- package/dist/facets/vite-dev-server.js +4 -4
- package/dist/git/commands.d.ts +8 -0
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +41 -9
- package/dist/git/network-facet.d.ts +1 -1
- package/dist/git/network-facet.d.ts.map +1 -1
- package/dist/git/network-facet.js +35 -12
- package/dist/git-bundle.generated.d.ts +2 -2
- package/dist/git-bundle.generated.d.ts.map +1 -1
- package/dist/git-bundle.generated.js +3 -3
- package/dist/index.js +1 -1
- package/dist/loaders/child-process/spawn-facet.js +1 -1
- package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -1
- package/dist/loaders/child-process/spawn-pool.js +2 -2
- package/dist/loaders/generated-workers.d.ts +1 -1
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +2 -2
- package/dist/loaders/npm-resolve-preamble.d.ts +3 -3
- package/dist/loaders/npm-resolve-preamble.js +3 -3
- package/dist/loaders/pre-bundle-preamble.d.ts +5 -5
- package/dist/loaders/pre-bundle-preamble.js +6 -6
- package/dist/loaders/process-host.d.ts +6 -107
- package/dist/loaders/process-host.d.ts.map +1 -1
- package/dist/loaders/process-host.js +6 -405
- package/dist/npm/install-batch-facet.js +1 -1
- package/dist/npm/installer.d.ts +4 -4
- package/dist/npm/installer.js +18 -18
- package/dist/npm/pre-bundle-facet.d.ts +2 -2
- package/dist/npm/pre-bundle-facet.js +5 -5
- package/dist/npm/resolve-facet.d.ts +1 -1
- package/dist/npm/resolve-facet.js +1 -1
- package/dist/npm/resolve-one-facet.d.ts +5 -5
- package/dist/npm/resolve-one-facet.js +5 -5
- package/dist/router/index.js +1 -1
- package/dist/router/remote-api.js +8 -0
- package/dist/runtime/bun-repl.d.ts +1 -1
- package/dist/runtime/bun-repl.js +3 -3
- package/dist/runtime/facet-loader-host.d.ts +5 -8
- package/dist/runtime/facet-loader-host.d.ts.map +1 -1
- package/dist/runtime/facet-loader-host.js +7 -11
- package/dist/runtime/node-repl.js +2 -2
- package/dist/runtime/python-repl.js +3 -3
- package/dist/runtime/ruby-repl.js +2 -2
- package/dist/runtime/ruby-resident.js +1 -1
- package/dist/session/hibernation.d.ts +18 -51
- package/dist/session/hibernation.d.ts.map +1 -1
- package/dist/session/hibernation.js +49 -186
- package/dist/session/init-phases.d.ts +2 -2
- package/dist/session/init-phases.d.ts.map +1 -1
- package/dist/session/init-phases.js +1 -1
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +16 -2
- package/dist/session/keys.d.ts +14 -35
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js +17 -35
- package/dist/session/nimbus-session.d.ts +10 -4
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +20 -11
- package/dist/session/port-capability.d.ts +43 -0
- package/dist/session/port-capability.d.ts.map +1 -0
- package/dist/session/port-capability.js +49 -0
- package/dist/session/programmatic.d.ts +41 -5
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +147 -15
- package/dist/session/routes.d.ts +2 -0
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +91 -16
- package/dist/session/rpc.d.ts +35 -8
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +73 -14
- package/dist/session/start-real-vite.d.ts.map +1 -1
- package/dist/session/start-real-vite.js +2 -0
- package/dist/session/state-store.d.ts +3 -2
- package/dist/session/state-store.d.ts.map +1 -1
- package/dist/session/state-store.js +3 -2
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +5 -0
- package/dist/session/ws.d.ts +2 -2
- package/dist/session/ws.d.ts.map +1 -1
- package/dist/session/ws.js +2 -2
- package/dist/wrangler/nimbus-wrangler.js +1 -1
- package/package.json +3 -2
- package/scripts/bundle-runtime.mjs +5 -2
- package/dist/facets/inner-do-registry.d.ts +0 -41
- package/dist/facets/inner-do-registry.d.ts.map +0 -1
- package/dist/facets/inner-do-registry.js +0 -51
- package/dist/facets/launch-pacer.d.ts +0 -111
- package/dist/facets/launch-pacer.d.ts.map +0 -1
- package/dist/facets/launch-pacer.js +0 -130
- package/dist/loaders/fanout-pool.d.ts +0 -207
- package/dist/loaders/fanout-pool.d.ts.map +0 -1
- package/dist/loaders/fanout-pool.js +0 -363
- package/dist/loaders/loader-pool.d.ts +0 -294
- package/dist/loaders/loader-pool.d.ts.map +0 -1
- package/dist/loaders/loader-pool.js +0 -642
- package/dist/loaders/process-fabric.d.ts +0 -509
- package/dist/loaders/process-fabric.d.ts.map +0 -1
- package/dist/loaders/process-fabric.js +0 -360
- package/dist/loaders/vendor/errors.d.ts +0 -24
- package/dist/loaders/vendor/errors.d.ts.map +0 -1
- package/dist/loaders/vendor/errors.js +0 -46
- package/dist/loaders/vendor/serialize.d.ts +0 -3
- package/dist/loaders/vendor/serialize.d.ts.map +0 -1
- package/dist/loaders/vendor/serialize.js +0 -25
- package/dist/loaders/vendor/types.d.ts +0 -69
- package/dist/loaders/vendor/types.d.ts.map +0 -1
- package/dist/loaders/vendor/types.js +0 -4
- package/dist/loaders/workerd-facet-host.d.ts +0 -141
- package/dist/loaders/workerd-facet-host.d.ts.map +0 -1
- package/dist/loaders/workerd-facet-host.js +0 -284
- package/dist/session/bindings.d.ts +0 -209
- package/dist/session/bindings.d.ts.map +0 -1
- package/dist/session/bindings.js +0 -680
- package/dist/session/ctx-exports.d.ts +0 -16
- package/dist/session/ctx-exports.d.ts.map +0 -1
- package/dist/session/ctx-exports.js +0 -22
- package/dist/session/ws-hibernation-config.d.ts +0 -64
- package/dist/session/ws-hibernation-config.d.ts.map +0 -1
- package/dist/session/ws-hibernation-config.js +0 -89
|
@@ -22,6 +22,7 @@ import { CirrusReal } from '../facets/cirrus-real.js';
|
|
|
22
22
|
import { makeLongRunningPortStub } from '@nimbus-sh/core/runtime/long-running-handle.js';
|
|
23
23
|
import { acquireHeavyAlloc } from '@nimbus-sh/core/observability/heavy-alloc-coord.js';
|
|
24
24
|
import { VITE_CONFIG_KEY } from './keys.js';
|
|
25
|
+
import { clearPortCapability } from './port-capability.js';
|
|
25
26
|
/**
|
|
26
27
|
* Boot a cirrus-real dev server on `self`, register its port, and persist the
|
|
27
28
|
* config restore needs. `self` is the session host (RoutesHost/InitHost = any).
|
|
@@ -110,6 +111,7 @@ export async function startRealVite(self, opts) {
|
|
|
110
111
|
// only difference is which handler.handleRequest the stub forwards into.
|
|
111
112
|
const cirrusStub = makeLongRunningPortStub(cirrusReal);
|
|
112
113
|
self.portRegistry.bindFacetStub(entry.pid, cirrusStub);
|
|
114
|
+
await clearPortCapability(self, opts.port);
|
|
113
115
|
self.portRegistry.register(opts.port, entry.pid);
|
|
114
116
|
self._viteShimPid = entry.pid;
|
|
115
117
|
self._viteShimPort = opts.port;
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
* npm-install side-effects 100 vars), we want to surface that as a
|
|
49
49
|
* clear error rather than a silent storage-row-too-long failure.
|
|
50
50
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* DO SQLite caps a string, BLOB or table row at 2 MB
|
|
52
|
+
* (https://developers.cloudflare.com/durable-objects/platform/limits/);
|
|
53
|
+
* we set a much tighter 256 KiB ceiling so a misbehaving
|
|
53
54
|
* session can't approach the platform limit. */
|
|
54
55
|
export declare const SESSION_ENV_MAX_BYTES: number;
|
|
55
56
|
/** Module-level cap on the per-session terminal scrollback in DO
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-store.d.ts","sourceRoot":"","sources":["../../src/session/state-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH
|
|
1
|
+
{"version":3,"file":"state-store.d.ts","sourceRoot":"","sources":["../../src/session/state-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;;;;;;;iDAQiD;AACjD,eAAO,MAAM,qBAAqB,QAAa,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;qEAyBqE;AACrE,eAAO,MAAM,oBAAoB,QAAc,CAAC;AAChD;;;;;;aAMa;AACb,eAAO,MAAM,0BAA0B,QAAa,CAAC;AAErD;mCACmC;AACnC,eAAO,MAAM,OAAO,QAAQ,CAAC;AAC7B,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,2EAA2E;AAC3E,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACnC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;iDAE6C;IAC7C,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAiCvD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,kBAAkB,CAqC3D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE;IAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;CAAE,GAChE,IAAI,CA6BN;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAQ5D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAOhD;AAED;;+BAE+B;AAC/B,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAQtD;AAaD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,CAWnD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAcpE;AAwBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CA6E3E;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAW/C;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;CAC/C,CAaA"}
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
* npm-install side-effects 100 vars), we want to surface that as a
|
|
49
49
|
* clear error rather than a silent storage-row-too-long failure.
|
|
50
50
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* DO SQLite caps a string, BLOB or table row at 2 MB
|
|
52
|
+
* (https://developers.cloudflare.com/durable-objects/platform/limits/);
|
|
53
|
+
* we set a much tighter 256 KiB ceiling so a misbehaving
|
|
53
54
|
* session can't approach the platform limit. */
|
|
54
55
|
export const SESSION_ENV_MAX_BYTES = 256 * 1024;
|
|
55
56
|
/** Module-level cap on the per-session terminal scrollback in DO
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor-rpc.d.ts","sourceRoot":"","sources":["../../src/session/supervisor-rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"supervisor-rpc.d.ts","sourceRoot":"","sources":["../../src/session/supervisor-rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAUrE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAEnF;;;;;;;GAOG;AACH,MAAM,MAAM,wBAAwB,GAChC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AA2C5D,qBAAa,aAAc,SAAQ,gBA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AAC;CAGH"}
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
* prefetch(cwd, entryCode) → Record<string, string>
|
|
30
30
|
*/
|
|
31
31
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
32
|
+
import { setSupervisorEntrypointName } from '@nimbus-sh/fabric/ctx-exports.js';
|
|
32
33
|
// W5: OOM discriminator — record last-known RPC frame on writeBatch entry
|
|
33
34
|
import { setLastRpcFrame } from '@nimbus-sh/core/observability/oom-discriminator.js';
|
|
34
35
|
// Phase 2 A'.2 — supervisor in-flight RPC payload byte tracking.
|
|
@@ -74,6 +75,10 @@ function _estimateWriteBatchBytes(payload) {
|
|
|
74
75
|
n += 80 + (i?.path?.length ?? 0);
|
|
75
76
|
return n;
|
|
76
77
|
}
|
|
78
|
+
// The fabric mints `env.SUPERVISOR` bindings for the programs it hosts;
|
|
79
|
+
// this names the ctx.exports entrypoint those bindings resolve to. Module
|
|
80
|
+
// scope so every isolate that can reach the fabric has it before first use.
|
|
81
|
+
setSupervisorEntrypointName('SupervisorRPC');
|
|
77
82
|
export class SupervisorRPC extends WorkerEntrypoint {
|
|
78
83
|
/**
|
|
79
84
|
* The supervisor DO stub for RPC routing, found from the doId in ctx.props.
|
package/dist/session/ws.d.ts
CHANGED
|
@@ -60,8 +60,8 @@ export interface WsHost {
|
|
|
60
60
|
_w9PersistWired: boolean;
|
|
61
61
|
_w9FlushTimer: any;
|
|
62
62
|
_w9SchemaInit: boolean;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
_isolateGen: number;
|
|
64
|
+
_isolateGenPersisted: boolean;
|
|
65
65
|
_w9WsConfig: any;
|
|
66
66
|
_diagPeakRss: number;
|
|
67
67
|
_diagPeakHeapUsed: number;
|
package/dist/session/ws.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/session/ws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;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B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA0CD,wBAAgB,MAAM,CAAC,EAAE,EAAE,SAAS,GAAG,YAAY,CAElD;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuEzG;AA+CD,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,SAAS,EACb,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,IAAI,CAAC,CA4Ff;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAuEtF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAUlD"}
|
package/dist/session/ws.js
CHANGED
|
@@ -320,7 +320,7 @@ export async function wsClose(self, ws, _code, _reason, _wasClean) {
|
|
|
320
320
|
fromState: 'active',
|
|
321
321
|
toState: 'drained',
|
|
322
322
|
trigger: 'ws-close',
|
|
323
|
-
isolateGen: self.
|
|
323
|
+
isolateGen: self._isolateGen,
|
|
324
324
|
dataLoss: false,
|
|
325
325
|
snapshotKeysRehydrated: 0,
|
|
326
326
|
});
|
|
@@ -400,7 +400,7 @@ export async function wsError(self, ws, _error) {
|
|
|
400
400
|
fromState: 'active',
|
|
401
401
|
toState: 'drained',
|
|
402
402
|
trigger: 'ws-error',
|
|
403
|
-
isolateGen: self.
|
|
403
|
+
isolateGen: self._isolateGen,
|
|
404
404
|
dataLoss: false,
|
|
405
405
|
snapshotKeysRehydrated: 0,
|
|
406
406
|
});
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Cloudflare Workers runtime, not a simulation.
|
|
15
15
|
*/
|
|
16
16
|
import { normalizeVfsPath } from '@nimbus-sh/core/vfs/path.js';
|
|
17
|
-
import { registerInnerDoClass, clearInnerDoClasses } from '
|
|
17
|
+
import { registerInnerDoClass, clearInnerDoClasses } from '@nimbus-sh/fabric/inner-do-registry.js';
|
|
18
18
|
import { KvEmulator } from '../bindings/kv.js';
|
|
19
19
|
import { D1Emulator } from '../bindings/d1.js';
|
|
20
20
|
import { R2Emulator } from '../bindings/r2.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimbus-sh/worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Nimbus runtime package for Cloudflare Workers, re-exported publicly through @nimbus-sh/sdk/worker.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -84,7 +84,8 @@
|
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@ai-sdk/openai-compatible": "^2.0.41",
|
|
87
|
-
"@nimbus-sh/core": "^0.
|
|
87
|
+
"@nimbus-sh/core": "^0.5.0",
|
|
88
|
+
"@nimbus-sh/fabric": "^0.1.0",
|
|
88
89
|
"@renovatebot/pep440": "^5.0.0",
|
|
89
90
|
"ai": "^6.0.182",
|
|
90
91
|
"clean-git-ref": "^2.0.1",
|
|
@@ -927,8 +927,11 @@ function writeNpmPackage(outDir, manifest, downloaded) {
|
|
|
927
927
|
},
|
|
928
928
|
files: ['index.js', 'index.d.ts', 'manifest.json', 'blobs', 'LICENSE', 'README.md'],
|
|
929
929
|
// The runtime is inert without the half that installs and runs it, and
|
|
930
|
-
// `index.d.ts` types itself against that package's exports.
|
|
931
|
-
|
|
930
|
+
// `index.d.ts` types itself against that package's exports. The floor is
|
|
931
|
+
// the core release whose FacetHost carries every runner generated from
|
|
932
|
+
// this tree — earlier cores would seed the files and then have no
|
|
933
|
+
// command to run them.
|
|
934
|
+
peerDependencies: { '@nimbus-sh/core': '>=0.4.0' },
|
|
932
935
|
publishConfig: { access: 'public' },
|
|
933
936
|
}, null, 2)}\n`);
|
|
934
937
|
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inner-do-registry.ts — Module-level registry of inner DO classes.
|
|
3
|
-
*
|
|
4
|
-
* `nimbus-wrangler` populates this on each successful buildAndLoad()
|
|
5
|
-
* with the DurableObject classes extracted from the freshly-loaded
|
|
6
|
-
* inner Worker via `worker.getDurableObjectClass(name)`. The supervisor
|
|
7
|
-
* DO (`NimbusSession`) reads it on each inner-DO fetch to synthesize a
|
|
8
|
-
* NimbusDurableObjectNamespace stub for `env.MY_DO`.
|
|
9
|
-
*
|
|
10
|
-
* Why a separate leaf module:
|
|
11
|
-
* Before this extraction, the registry lived inside nimbus-session.ts,
|
|
12
|
-
* which forced nimbus-wrangler.ts to import from nimbus-session.ts —
|
|
13
|
-
* producing the cycle
|
|
14
|
-
* index.ts -> nimbus-session.ts -> nimbus-wrangler.ts -> nimbus-session.ts
|
|
15
|
-
* Promoting the registry to its own leaf breaks that cycle without
|
|
16
|
-
* changing any semantics. The Map identity is preserved across the
|
|
17
|
-
* isolate (it's still process-scoped — module-level state — survives
|
|
18
|
-
* across DO instances in the same workerd process).
|
|
19
|
-
*
|
|
20
|
-
* Key shape:
|
|
21
|
-
* `<supervisor-DO-id>:<binding-name>` — both halves are required to
|
|
22
|
-
* prevent multiple supervisor DOs in the same isolate from clobbering
|
|
23
|
-
* each other's registrations.
|
|
24
|
-
*
|
|
25
|
-
* The values are DurableObject class constructors. `any` here is
|
|
26
|
-
* deliberate: the inner DO's class shape is whatever the user defines
|
|
27
|
-
* in their inner Worker, and we only need to invoke it via
|
|
28
|
-
* `ctx.facets.get(name, { class: cls, id })` — workerd does the rest.
|
|
29
|
-
*/
|
|
30
|
-
/** Look up a registered inner-DO class. Returns undefined if not found. */
|
|
31
|
-
export declare function getInnerDoClass(supervisorDoId: string, bindingName: string): any | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Register an inner DO class for synthesis. Called by nimbus-wrangler.ts
|
|
34
|
-
* after each successful buildAndLoad() with the class extracted from
|
|
35
|
-
* the fresh worker stub. Keys are `<doId>:<bindingName>` so multiple
|
|
36
|
-
* supervisor DOs don't collide.
|
|
37
|
-
*/
|
|
38
|
-
export declare function registerInnerDoClass(supervisorDoId: string, bindingName: string, cls: any): void;
|
|
39
|
-
/** Clear all registrations belonging to a supervisor DO (called on rebuild). */
|
|
40
|
-
export declare function clearInnerDoClasses(supervisorDoId: string): void;
|
|
41
|
-
//# sourceMappingURL=inner-do-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inner-do-registry.d.ts","sourceRoot":"","sources":["../../src/facets/inner-do-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAE5F;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,GAAG,GACP,IAAI,CAEN;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAKhE"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inner-do-registry.ts — Module-level registry of inner DO classes.
|
|
3
|
-
*
|
|
4
|
-
* `nimbus-wrangler` populates this on each successful buildAndLoad()
|
|
5
|
-
* with the DurableObject classes extracted from the freshly-loaded
|
|
6
|
-
* inner Worker via `worker.getDurableObjectClass(name)`. The supervisor
|
|
7
|
-
* DO (`NimbusSession`) reads it on each inner-DO fetch to synthesize a
|
|
8
|
-
* NimbusDurableObjectNamespace stub for `env.MY_DO`.
|
|
9
|
-
*
|
|
10
|
-
* Why a separate leaf module:
|
|
11
|
-
* Before this extraction, the registry lived inside nimbus-session.ts,
|
|
12
|
-
* which forced nimbus-wrangler.ts to import from nimbus-session.ts —
|
|
13
|
-
* producing the cycle
|
|
14
|
-
* index.ts -> nimbus-session.ts -> nimbus-wrangler.ts -> nimbus-session.ts
|
|
15
|
-
* Promoting the registry to its own leaf breaks that cycle without
|
|
16
|
-
* changing any semantics. The Map identity is preserved across the
|
|
17
|
-
* isolate (it's still process-scoped — module-level state — survives
|
|
18
|
-
* across DO instances in the same workerd process).
|
|
19
|
-
*
|
|
20
|
-
* Key shape:
|
|
21
|
-
* `<supervisor-DO-id>:<binding-name>` — both halves are required to
|
|
22
|
-
* prevent multiple supervisor DOs in the same isolate from clobbering
|
|
23
|
-
* each other's registrations.
|
|
24
|
-
*
|
|
25
|
-
* The values are DurableObject class constructors. `any` here is
|
|
26
|
-
* deliberate: the inner DO's class shape is whatever the user defines
|
|
27
|
-
* in their inner Worker, and we only need to invoke it via
|
|
28
|
-
* `ctx.facets.get(name, { class: cls, id })` — workerd does the rest.
|
|
29
|
-
*/
|
|
30
|
-
const _NIMBUS_INNER_DO_CLASSES = new Map();
|
|
31
|
-
/** Look up a registered inner-DO class. Returns undefined if not found. */
|
|
32
|
-
export function getInnerDoClass(supervisorDoId, bindingName) {
|
|
33
|
-
return _NIMBUS_INNER_DO_CLASSES.get(supervisorDoId + ':' + bindingName);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Register an inner DO class for synthesis. Called by nimbus-wrangler.ts
|
|
37
|
-
* after each successful buildAndLoad() with the class extracted from
|
|
38
|
-
* the fresh worker stub. Keys are `<doId>:<bindingName>` so multiple
|
|
39
|
-
* supervisor DOs don't collide.
|
|
40
|
-
*/
|
|
41
|
-
export function registerInnerDoClass(supervisorDoId, bindingName, cls) {
|
|
42
|
-
_NIMBUS_INNER_DO_CLASSES.set(supervisorDoId + ':' + bindingName, cls);
|
|
43
|
-
}
|
|
44
|
-
/** Clear all registrations belonging to a supervisor DO (called on rebuild). */
|
|
45
|
-
export function clearInnerDoClasses(supervisorDoId) {
|
|
46
|
-
const prefix = supervisorDoId + ':';
|
|
47
|
-
for (const k of _NIMBUS_INNER_DO_CLASSES.keys()) {
|
|
48
|
-
if (k.startsWith(prefix))
|
|
49
|
-
_NIMBUS_INNER_DO_CLASSES.delete(k);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* launch-pacer.ts — spreading a resident launch across Durable Object turns.
|
|
3
|
-
*
|
|
4
|
-
* Building a resident process is the largest single span of computation this
|
|
5
|
-
* session performs: for pi it walks a 17 MB source tree through eight
|
|
6
|
-
* enrichment passes, serializes a 22.9 MB module map, and writes that map into
|
|
7
|
-
* the image store. Done in one turn it occupied the session DO's only thread
|
|
8
|
-
* for 15-35 s, and a session that cannot reach its thread cannot service the
|
|
9
|
-
* terminal WebSocket — the launch turn finished `outcome=ok` and the terminal
|
|
10
|
-
* died anyway, painting "[process terminal closed]" over a process that was
|
|
11
|
-
* still running.
|
|
12
|
-
*
|
|
13
|
-
* A faster launch does not fix that. A launch half the length still blocks the
|
|
14
|
-
* thread for as long as it runs, and the socket is dropped inside that window
|
|
15
|
-
* whether or not the work succeeds. What fixes it is never holding the thread
|
|
16
|
-
* for long in the first place, which means suspending the launch at bounded
|
|
17
|
-
* intervals and resuming it on a fresh turn. Responsiveness stops depending on
|
|
18
|
-
* how long the total work takes.
|
|
19
|
-
*
|
|
20
|
-
* A fresh turn is also a fresh CPU budget. The same launches that dropped the
|
|
21
|
-
* socket were also being killed with `exceededCpu` at 31.8 s and 32.5 s
|
|
22
|
-
* against a 30 s ceiling, and no amount of yielding *within* one invocation
|
|
23
|
-
* moves that: CPU accrues to the invocation, not to the pause. Only genuinely
|
|
24
|
-
* re-entering the object resets it.
|
|
25
|
-
*
|
|
26
|
-
* Progress is measured in bytes rather than milliseconds because workerd's
|
|
27
|
-
* clock does not advance without I/O — a wall-clock guard inside a span of
|
|
28
|
-
* pure computation reads zero however many seconds it burns, which is why the
|
|
29
|
-
* phase costs behind this module had to be recovered from per-turn `cpuTime`
|
|
30
|
-
* rather than measured in place. Bytes are what the work is actually
|
|
31
|
-
* proportional to, and they are exact. The same reasoning is why
|
|
32
|
-
* `git/network-facet.ts` bounds its checkout chunks by entries and decoded
|
|
33
|
-
* bytes and treats its wall guard as coarse.
|
|
34
|
-
*/
|
|
35
|
-
/** How a paced launch gets back onto a fresh Durable Object turn. */
|
|
36
|
-
export interface LaunchTurnScheduler {
|
|
37
|
-
/**
|
|
38
|
-
* Suspend until a fresh turn is running this launch again.
|
|
39
|
-
*
|
|
40
|
-
* `chunkEnded` settles when the resumed launch reaches its next suspension
|
|
41
|
-
* point or finishes, so whoever grants the turn can await the work it just
|
|
42
|
-
* released rather than letting it run detached in a handler's microtask
|
|
43
|
-
* drain.
|
|
44
|
-
*/
|
|
45
|
-
nextTurn(chunkEnded: Promise<void>): Promise<void>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Bytes of launch work one turn may perform before it must yield.
|
|
49
|
-
*
|
|
50
|
-
* Sized so a chunk stays far below both the CPU ceiling and the span in which
|
|
51
|
-
* a terminal socket is at risk, while keeping the number of turn handoffs —
|
|
52
|
-
* each an alarm round trip — small enough not to dominate a launch. pi's
|
|
53
|
-
* 22.9 MB map crosses this about a dozen times per phase that handles it.
|
|
54
|
-
*/
|
|
55
|
-
export declare const LAUNCH_CHUNK_MAX_BYTES = 2000000;
|
|
56
|
-
/**
|
|
57
|
-
* Accounts launch progress and ends the turn when a chunk's worth has been
|
|
58
|
-
* spent.
|
|
59
|
-
*
|
|
60
|
-
* Callers report the work they are about to do or have just done and await
|
|
61
|
-
* the result; a pacer that is not yielding returns without suspending, so the
|
|
62
|
-
* one-shot exec path — which passes no pacer at all — keeps its exact
|
|
63
|
-
* behaviour and cost. Nothing here decides WHAT the launch does, only where it
|
|
64
|
-
* is allowed to stop.
|
|
65
|
-
*/
|
|
66
|
-
export declare class LaunchPacer {
|
|
67
|
-
private readonly scheduler;
|
|
68
|
-
private readonly maxChunkBytes;
|
|
69
|
-
private readonly stillWanted?;
|
|
70
|
-
/** Turn handoffs this launch has taken. Reported with the launch. */
|
|
71
|
-
chunks: number;
|
|
72
|
-
/** Total work accounted, for the same report. */
|
|
73
|
-
bytes: number;
|
|
74
|
-
private spent;
|
|
75
|
-
private chunkEnded;
|
|
76
|
-
/**
|
|
77
|
-
* @param stillWanted Checked every time the launch resumes. A launch spans
|
|
78
|
-
* many turns, so anything may have happened to what it is building for
|
|
79
|
-
* while it was suspended; throwing from here is how a launch stops instead
|
|
80
|
-
* of spending turn after turn on work nothing will use. Checked at the one
|
|
81
|
-
* place a launch can be interrupted, rather than at whichever phases
|
|
82
|
-
* remembered to ask.
|
|
83
|
-
*/
|
|
84
|
-
constructor(scheduler: LaunchTurnScheduler, maxChunkBytes?: number, stillWanted?: (() => void) | undefined);
|
|
85
|
-
/**
|
|
86
|
-
* Account `bytes` of completed work, ending the turn if a chunk is full.
|
|
87
|
-
*
|
|
88
|
-
* Safe to call anywhere the launch holds no state that a concurrent turn
|
|
89
|
-
* could invalidate — which is why the image store registers its whole root
|
|
90
|
-
* set before the first call rather than one entry at a time.
|
|
91
|
-
*/
|
|
92
|
-
spend(bytes: number): Promise<void>;
|
|
93
|
-
/**
|
|
94
|
-
* The launch has finished (or failed). Releases the turn still waiting on
|
|
95
|
-
* the chunk it resumed, so a launch that ends mid-chunk does not strand the
|
|
96
|
-
* handler that granted it.
|
|
97
|
-
*/
|
|
98
|
-
settle(): void;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Chunk bound for this session, honouring the verification knob.
|
|
102
|
-
*
|
|
103
|
-
* `NIMBUS_LAUNCH_CHUNK_BYTES` forces a small bound so an ordinary launch —
|
|
104
|
-
* not just a pathological one — crosses several turns and exercises every
|
|
105
|
-
* suspension point. Without it the multi-turn path would only ever be
|
|
106
|
-
* reached by the largest programs, which is the same reason
|
|
107
|
-
* `git/commands.ts` carries `NIMBUS_GIT_CHECKOUT_CHUNK_ENTRIES`. Unset in
|
|
108
|
-
* production, where the default applies.
|
|
109
|
-
*/
|
|
110
|
-
export declare function launchChunkMaxBytes(env: unknown): number;
|
|
111
|
-
//# sourceMappingURL=launch-pacer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"launch-pacer.d.ts","sourceRoot":"","sources":["../../src/facets/launch-pacer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,qEAAqE;AACrE,MAAM,WAAW,mBAAmB;IAClC;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAEhD;;;;;;;;;GASG;AACH,qBAAa,WAAW;IAkBpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAnB/B,qEAAqE;IACrE,MAAM,SAAK;IACX,iDAAiD;IACjD,KAAK,SAAK;IAEV,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,UAAU,CAA8D;IAEhF;;;;;;;OAOG;gBAEgB,SAAS,EAAE,mBAAmB,EAC9B,aAAa,GAAE,MAA+B,EAC9C,WAAW,CAAC,GAAE,MAAM,IAAI,aAAA;IAG3C;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAczC;;;;OAIG;IACH,MAAM,IAAI,IAAI;CAIf;AAQD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAMxD"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* launch-pacer.ts — spreading a resident launch across Durable Object turns.
|
|
3
|
-
*
|
|
4
|
-
* Building a resident process is the largest single span of computation this
|
|
5
|
-
* session performs: for pi it walks a 17 MB source tree through eight
|
|
6
|
-
* enrichment passes, serializes a 22.9 MB module map, and writes that map into
|
|
7
|
-
* the image store. Done in one turn it occupied the session DO's only thread
|
|
8
|
-
* for 15-35 s, and a session that cannot reach its thread cannot service the
|
|
9
|
-
* terminal WebSocket — the launch turn finished `outcome=ok` and the terminal
|
|
10
|
-
* died anyway, painting "[process terminal closed]" over a process that was
|
|
11
|
-
* still running.
|
|
12
|
-
*
|
|
13
|
-
* A faster launch does not fix that. A launch half the length still blocks the
|
|
14
|
-
* thread for as long as it runs, and the socket is dropped inside that window
|
|
15
|
-
* whether or not the work succeeds. What fixes it is never holding the thread
|
|
16
|
-
* for long in the first place, which means suspending the launch at bounded
|
|
17
|
-
* intervals and resuming it on a fresh turn. Responsiveness stops depending on
|
|
18
|
-
* how long the total work takes.
|
|
19
|
-
*
|
|
20
|
-
* A fresh turn is also a fresh CPU budget. The same launches that dropped the
|
|
21
|
-
* socket were also being killed with `exceededCpu` at 31.8 s and 32.5 s
|
|
22
|
-
* against a 30 s ceiling, and no amount of yielding *within* one invocation
|
|
23
|
-
* moves that: CPU accrues to the invocation, not to the pause. Only genuinely
|
|
24
|
-
* re-entering the object resets it.
|
|
25
|
-
*
|
|
26
|
-
* Progress is measured in bytes rather than milliseconds because workerd's
|
|
27
|
-
* clock does not advance without I/O — a wall-clock guard inside a span of
|
|
28
|
-
* pure computation reads zero however many seconds it burns, which is why the
|
|
29
|
-
* phase costs behind this module had to be recovered from per-turn `cpuTime`
|
|
30
|
-
* rather than measured in place. Bytes are what the work is actually
|
|
31
|
-
* proportional to, and they are exact. The same reasoning is why
|
|
32
|
-
* `git/network-facet.ts` bounds its checkout chunks by entries and decoded
|
|
33
|
-
* bytes and treats its wall guard as coarse.
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* Bytes of launch work one turn may perform before it must yield.
|
|
37
|
-
*
|
|
38
|
-
* Sized so a chunk stays far below both the CPU ceiling and the span in which
|
|
39
|
-
* a terminal socket is at risk, while keeping the number of turn handoffs —
|
|
40
|
-
* each an alarm round trip — small enough not to dominate a launch. pi's
|
|
41
|
-
* 22.9 MB map crosses this about a dozen times per phase that handles it.
|
|
42
|
-
*/
|
|
43
|
-
export const LAUNCH_CHUNK_MAX_BYTES = 2_000_000;
|
|
44
|
-
/**
|
|
45
|
-
* Accounts launch progress and ends the turn when a chunk's worth has been
|
|
46
|
-
* spent.
|
|
47
|
-
*
|
|
48
|
-
* Callers report the work they are about to do or have just done and await
|
|
49
|
-
* the result; a pacer that is not yielding returns without suspending, so the
|
|
50
|
-
* one-shot exec path — which passes no pacer at all — keeps its exact
|
|
51
|
-
* behaviour and cost. Nothing here decides WHAT the launch does, only where it
|
|
52
|
-
* is allowed to stop.
|
|
53
|
-
*/
|
|
54
|
-
export class LaunchPacer {
|
|
55
|
-
scheduler;
|
|
56
|
-
maxChunkBytes;
|
|
57
|
-
stillWanted;
|
|
58
|
-
/** Turn handoffs this launch has taken. Reported with the launch. */
|
|
59
|
-
chunks = 0;
|
|
60
|
-
/** Total work accounted, for the same report. */
|
|
61
|
-
bytes = 0;
|
|
62
|
-
spent = 0;
|
|
63
|
-
chunkEnded;
|
|
64
|
-
/**
|
|
65
|
-
* @param stillWanted Checked every time the launch resumes. A launch spans
|
|
66
|
-
* many turns, so anything may have happened to what it is building for
|
|
67
|
-
* while it was suspended; throwing from here is how a launch stops instead
|
|
68
|
-
* of spending turn after turn on work nothing will use. Checked at the one
|
|
69
|
-
* place a launch can be interrupted, rather than at whichever phases
|
|
70
|
-
* remembered to ask.
|
|
71
|
-
*/
|
|
72
|
-
constructor(scheduler, maxChunkBytes = LAUNCH_CHUNK_MAX_BYTES, stillWanted) {
|
|
73
|
-
this.scheduler = scheduler;
|
|
74
|
-
this.maxChunkBytes = maxChunkBytes;
|
|
75
|
-
this.stillWanted = stillWanted;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Account `bytes` of completed work, ending the turn if a chunk is full.
|
|
79
|
-
*
|
|
80
|
-
* Safe to call anywhere the launch holds no state that a concurrent turn
|
|
81
|
-
* could invalidate — which is why the image store registers its whole root
|
|
82
|
-
* set before the first call rather than one entry at a time.
|
|
83
|
-
*/
|
|
84
|
-
async spend(bytes) {
|
|
85
|
-
this.bytes += bytes;
|
|
86
|
-
this.spent += bytes;
|
|
87
|
-
if (this.spent < this.maxChunkBytes)
|
|
88
|
-
return;
|
|
89
|
-
this.spent = 0;
|
|
90
|
-
this.chunks++;
|
|
91
|
-
// Release the turn that resumed us before asking for the next one.
|
|
92
|
-
this.chunkEnded?.resolve();
|
|
93
|
-
const ended = withResolvers();
|
|
94
|
-
this.chunkEnded = ended;
|
|
95
|
-
await this.scheduler.nextTurn(ended.promise);
|
|
96
|
-
this.stillWanted?.();
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* The launch has finished (or failed). Releases the turn still waiting on
|
|
100
|
-
* the chunk it resumed, so a launch that ends mid-chunk does not strand the
|
|
101
|
-
* handler that granted it.
|
|
102
|
-
*/
|
|
103
|
-
settle() {
|
|
104
|
-
this.chunkEnded?.resolve();
|
|
105
|
-
this.chunkEnded = undefined;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function withResolvers() {
|
|
109
|
-
let resolve;
|
|
110
|
-
const promise = new Promise((r) => { resolve = r; });
|
|
111
|
-
return { promise, resolve };
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Chunk bound for this session, honouring the verification knob.
|
|
115
|
-
*
|
|
116
|
-
* `NIMBUS_LAUNCH_CHUNK_BYTES` forces a small bound so an ordinary launch —
|
|
117
|
-
* not just a pathological one — crosses several turns and exercises every
|
|
118
|
-
* suspension point. Without it the multi-turn path would only ever be
|
|
119
|
-
* reached by the largest programs, which is the same reason
|
|
120
|
-
* `git/commands.ts` carries `NIMBUS_GIT_CHECKOUT_CHUNK_ENTRIES`. Unset in
|
|
121
|
-
* production, where the default applies.
|
|
122
|
-
*/
|
|
123
|
-
export function launchChunkMaxBytes(env) {
|
|
124
|
-
const raw = env
|
|
125
|
-
?.NIMBUS_LAUNCH_CHUNK_BYTES;
|
|
126
|
-
if (!raw)
|
|
127
|
-
return LAUNCH_CHUNK_MAX_BYTES;
|
|
128
|
-
const parsed = Number(raw);
|
|
129
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : LAUNCH_CHUNK_MAX_BYTES;
|
|
130
|
-
}
|