tywrap 0.8.0 → 0.9.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 (157) hide show
  1. package/README.md +22 -7
  2. package/SECURITY.md +39 -0
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/config/index.js +8 -0
  5. package/dist/config/index.js.map +1 -1
  6. package/dist/core/annotation-parser.d.ts +2 -1
  7. package/dist/core/annotation-parser.d.ts.map +1 -1
  8. package/dist/core/annotation-parser.js +6 -3
  9. package/dist/core/annotation-parser.js.map +1 -1
  10. package/dist/core/generator.d.ts +23 -4
  11. package/dist/core/generator.d.ts.map +1 -1
  12. package/dist/core/generator.js +243 -170
  13. package/dist/core/generator.js.map +1 -1
  14. package/dist/core/mapper.d.ts +3 -2
  15. package/dist/core/mapper.d.ts.map +1 -1
  16. package/dist/core/mapper.js +5 -5
  17. package/dist/core/mapper.js.map +1 -1
  18. package/dist/index.d.ts +7 -5
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +6 -4
  21. package/dist/index.js.map +1 -1
  22. package/dist/runtime/base-bridge.d.ts +3 -7
  23. package/dist/runtime/base-bridge.d.ts.map +1 -1
  24. package/dist/runtime/base-bridge.js +4 -17
  25. package/dist/runtime/base-bridge.js.map +1 -1
  26. package/dist/runtime/bounded-context.d.ts +3 -22
  27. package/dist/runtime/bounded-context.d.ts.map +1 -1
  28. package/dist/runtime/bounded-context.js +13 -53
  29. package/dist/runtime/bounded-context.js.map +1 -1
  30. package/dist/runtime/bridge-codec.d.ts +1 -1
  31. package/dist/runtime/bridge-codec.d.ts.map +1 -1
  32. package/dist/runtime/bridge-codec.js +78 -55
  33. package/dist/runtime/bridge-codec.js.map +1 -1
  34. package/dist/runtime/errors.d.ts +16 -0
  35. package/dist/runtime/errors.d.ts.map +1 -1
  36. package/dist/runtime/errors.js +17 -0
  37. package/dist/runtime/errors.js.map +1 -1
  38. package/dist/runtime/http-transport.d.ts +1 -1
  39. package/dist/runtime/http-transport.d.ts.map +1 -1
  40. package/dist/runtime/http-transport.js +1 -1
  41. package/dist/runtime/http-transport.js.map +1 -1
  42. package/dist/runtime/index.d.ts +1 -0
  43. package/dist/runtime/index.d.ts.map +1 -1
  44. package/dist/runtime/index.js +1 -0
  45. package/dist/runtime/index.js.map +1 -1
  46. package/dist/runtime/node.d.ts +7 -36
  47. package/dist/runtime/node.d.ts.map +1 -1
  48. package/dist/runtime/node.js +2 -80
  49. package/dist/runtime/node.js.map +1 -1
  50. package/dist/runtime/pooled-transport.d.ts +120 -59
  51. package/dist/runtime/pooled-transport.d.ts.map +1 -1
  52. package/dist/runtime/pooled-transport.js +345 -78
  53. package/dist/runtime/pooled-transport.js.map +1 -1
  54. package/dist/runtime/pyodide-bootstrap-core.generated.d.ts.map +1 -1
  55. package/dist/runtime/pyodide-bootstrap-core.generated.js +1 -1
  56. package/dist/runtime/pyodide-bootstrap-core.generated.js.map +1 -1
  57. package/dist/runtime/pyodide-transport.d.ts +1 -1
  58. package/dist/runtime/pyodide-transport.d.ts.map +1 -1
  59. package/dist/runtime/pyodide-transport.js +2 -3
  60. package/dist/runtime/pyodide-transport.js.map +1 -1
  61. package/dist/runtime/rpc-client.d.ts +7 -36
  62. package/dist/runtime/rpc-client.d.ts.map +1 -1
  63. package/dist/runtime/rpc-client.js +20 -102
  64. package/dist/runtime/rpc-client.js.map +1 -1
  65. package/dist/runtime/subprocess-transport.d.ts +30 -69
  66. package/dist/runtime/subprocess-transport.d.ts.map +1 -1
  67. package/dist/runtime/subprocess-transport.js +179 -236
  68. package/dist/runtime/subprocess-transport.js.map +1 -1
  69. package/dist/runtime/timed-out-request-tracker.d.ts +2 -1
  70. package/dist/runtime/timed-out-request-tracker.d.ts.map +1 -1
  71. package/dist/runtime/transport.d.ts +9 -19
  72. package/dist/runtime/transport.d.ts.map +1 -1
  73. package/dist/runtime/transport.js +1 -1
  74. package/dist/runtime/transport.js.map +1 -1
  75. package/dist/runtime/validators.d.ts +49 -0
  76. package/dist/runtime/validators.d.ts.map +1 -1
  77. package/dist/runtime/validators.js +152 -0
  78. package/dist/runtime/validators.js.map +1 -1
  79. package/dist/types/index.d.ts +14 -39
  80. package/dist/types/index.d.ts.map +1 -1
  81. package/dist/tywrap.d.ts +3 -2
  82. package/dist/tywrap.d.ts.map +1 -1
  83. package/dist/tywrap.js +140 -13
  84. package/dist/tywrap.js.map +1 -1
  85. package/dist/utils/cache.d.ts +3 -16
  86. package/dist/utils/cache.d.ts.map +1 -1
  87. package/dist/utils/codec.d.ts +1 -0
  88. package/dist/utils/codec.d.ts.map +1 -1
  89. package/dist/utils/codec.js +13 -13
  90. package/dist/utils/codec.js.map +1 -1
  91. package/dist/utils/ir-cache.d.ts +2 -1
  92. package/dist/utils/ir-cache.d.ts.map +1 -1
  93. package/dist/utils/runtime.d.ts +0 -29
  94. package/dist/utils/runtime.d.ts.map +1 -1
  95. package/dist/utils/runtime.js +16 -107
  96. package/dist/utils/runtime.js.map +1 -1
  97. package/dist/version.js +1 -1
  98. package/package.json +7 -6
  99. package/runtime/frame_codec.py +7 -1
  100. package/runtime/python_bridge.py +85 -125
  101. package/runtime/tywrap_bridge_core.py +133 -150
  102. package/src/config/index.ts +11 -0
  103. package/src/core/annotation-parser.ts +7 -4
  104. package/src/core/generator.ts +315 -205
  105. package/src/core/mapper.ts +8 -8
  106. package/src/index.ts +7 -4
  107. package/src/runtime/base-bridge.ts +5 -30
  108. package/src/runtime/bounded-context.ts +12 -67
  109. package/src/runtime/bridge-codec.ts +94 -65
  110. package/src/runtime/errors.ts +21 -0
  111. package/src/runtime/http-transport.ts +6 -1
  112. package/src/runtime/index.ts +6 -0
  113. package/src/runtime/node.ts +9 -120
  114. package/src/runtime/pooled-transport.ts +424 -90
  115. package/src/runtime/pyodide-bootstrap-core.generated.ts +1 -1
  116. package/src/runtime/pyodide-transport.ts +7 -3
  117. package/src/runtime/rpc-client.ts +37 -139
  118. package/src/runtime/subprocess-transport.ts +210 -285
  119. package/src/runtime/timed-out-request-tracker.ts +1 -1
  120. package/src/runtime/transport.ts +15 -23
  121. package/src/runtime/validators.ts +204 -0
  122. package/src/types/index.ts +21 -60
  123. package/src/tywrap.ts +157 -22
  124. package/src/utils/cache.ts +3 -3
  125. package/src/utils/codec.ts +21 -13
  126. package/src/utils/ir-cache.ts +1 -1
  127. package/src/utils/runtime.ts +17 -128
  128. package/src/version.ts +1 -1
  129. package/dist/core/discovery.d.ts +0 -103
  130. package/dist/core/discovery.d.ts.map +0 -1
  131. package/dist/core/discovery.js +0 -380
  132. package/dist/core/discovery.js.map +0 -1
  133. package/dist/core/validation.d.ts +0 -102
  134. package/dist/core/validation.d.ts.map +0 -1
  135. package/dist/core/validation.js +0 -490
  136. package/dist/core/validation.js.map +0 -1
  137. package/dist/runtime/base.d.ts +0 -22
  138. package/dist/runtime/base.d.ts.map +0 -1
  139. package/dist/runtime/base.js +0 -23
  140. package/dist/runtime/base.js.map +0 -1
  141. package/dist/runtime/transport-pool.d.ts +0 -196
  142. package/dist/runtime/transport-pool.d.ts.map +0 -1
  143. package/dist/runtime/transport-pool.js +0 -418
  144. package/dist/runtime/transport-pool.js.map +0 -1
  145. package/runtime/__pycache__/_tywrap_conformance_chunking_fixtures.cpython-311.pyc +0 -0
  146. package/runtime/__pycache__/_tywrap_member_fixtures.cpython-311.pyc +0 -0
  147. package/runtime/__pycache__/_tywrap_w4_chunking_fixture.cpython-311.pyc +0 -0
  148. package/runtime/__pycache__/_tywrap_w5_request_chunking_fixture.cpython-311.pyc +0 -0
  149. package/runtime/__pycache__/_tywrap_w6_pool_chunking_fixture.cpython-311.pyc +0 -0
  150. package/runtime/__pycache__/frame_codec.cpython-311.pyc +0 -0
  151. package/runtime/__pycache__/safe_codec.cpython-311.pyc +0 -0
  152. package/runtime/__pycache__/tywrap_bridge_core.cpython-311.pyc +0 -0
  153. package/runtime/safe_codec.py +0 -352
  154. package/src/core/discovery.ts +0 -477
  155. package/src/core/validation.ts +0 -729
  156. package/src/runtime/base.ts +0 -24
  157. package/src/runtime/transport-pool.ts +0 -538
@@ -1,52 +1,50 @@
1
1
  /**
2
- * PooledTransport - Transport adapter that wraps TransportPool for multi-process support.
2
+ * PooledTransport - Manages multiple Transport instances for concurrent request handling.
3
3
  *
4
- * This transport implements the Transport interface by delegating to a TransportPool
5
- * of SubprocessTransport transports. Each send() acquires a worker, sends the message,
6
- * and releases the worker back to the pool.
4
+ * Provides semaphore-based concurrency control with configurable limits per worker
5
+ * and a wait queue for callers when all workers are at capacity.
7
6
  *
8
7
  * @see https://github.com/bbopen/tywrap/issues/149
9
8
  */
10
9
  import { DisposableBase } from './bounded-context.js';
11
- import { BridgeDisposedError, BridgeExecutionError } from './errors.js';
12
- import { TransportPool } from './transport-pool.js';
10
+ import { BridgeDisposedError, BridgeTimeoutError, BridgeExecutionError, BridgeProtocolError, } from './errors.js';
13
11
  // =============================================================================
14
- // POOLED TRANSPORT
12
+ // WORKER POOL
15
13
  // =============================================================================
16
14
  /**
17
- * Transport adapter that wraps TransportPool for multi-process message handling.
18
- *
19
- * PooledTransport presents a single Transport interface while internally
20
- * distributing requests across multiple worker transports (typically SubprocessTransport).
15
+ * Pool of Transport workers with semaphore-based concurrency control.
21
16
  *
22
17
  * Features:
23
- * - Lazy worker creation (transports created on demand)
24
- * - Configurable pool size and concurrency per worker
25
- * - Automatic worker acquisition and release
26
- * - Queue timeout for backpressure management
18
+ * - Lazy worker creation (workers created on demand)
19
+ * - Configurable concurrency per worker
20
+ * - Wait queue with timeout for callers when pool is at capacity
21
+ * - Automatic cleanup of timers and workers on disposal
27
22
  *
28
23
  * @example
29
24
  * ```typescript
30
- * const transport = new PooledTransport({
31
- * createTransport: () => new SubprocessTransport({
32
- * bridgeScript: '/path/to/bridge.py',
33
- * }),
25
+ * const pool = new PooledTransport({
26
+ * createTransport: () => new SubprocessTransport({ pythonPath: 'python3' }),
34
27
  * maxWorkers: 4,
35
28
  * maxConcurrentPerWorker: 2,
29
+ * queueTimeoutMs: 5000,
36
30
  * });
37
31
  *
38
- * await transport.init();
32
+ * await pool.init();
39
33
  *
40
- * // send() automatically uses pool
41
- * const response = await transport.send(message, timeout);
34
+ * // Use withWorker for automatic acquire/release
35
+ * const result = await pool.withWorker(async (worker) => {
36
+ * return worker.transport.send(message, timeout);
37
+ * });
42
38
  *
43
- * await transport.dispose();
39
+ * await pool.dispose();
44
40
  * ```
45
41
  */
46
42
  export class PooledTransport extends DisposableBase {
47
- poolOptions;
48
- pool;
49
- /** Memoized capability descriptor — built at most once (see {@link capabilities}). */
43
+ options;
44
+ workers = [];
45
+ waitQueue = [];
46
+ /** Tracks workers being created to prevent race condition in acquire() */
47
+ pendingCreations = 0;
50
48
  cachedCapabilities;
51
49
  /**
52
50
  * Create a new PooledTransport.
@@ -55,91 +53,230 @@ export class PooledTransport extends DisposableBase {
55
53
  */
56
54
  constructor(options) {
57
55
  super();
56
+ // Validate required options
58
57
  if (typeof options.createTransport !== 'function') {
59
58
  throw new BridgeExecutionError('createTransport must be a function');
60
59
  }
61
- this.poolOptions = {
60
+ const maxWorkers = options.maxWorkers ?? 1;
61
+ if (typeof maxWorkers !== 'number' || maxWorkers < 1) {
62
+ throw new BridgeExecutionError('maxWorkers must be a positive number');
63
+ }
64
+ const minWorkers = options.minWorkers ?? 0;
65
+ if (minWorkers > maxWorkers) {
66
+ throw new BridgeExecutionError('minWorkers cannot exceed maxWorkers');
67
+ }
68
+ this.options = {
62
69
  createTransport: options.createTransport,
63
- maxWorkers: options.maxWorkers ?? 1,
64
- minWorkers: options.minWorkers ?? 0,
70
+ maxWorkers,
71
+ minWorkers,
65
72
  queueTimeoutMs: options.queueTimeoutMs ?? 30000,
66
- maxConcurrentPerWorker: options.maxConcurrentPerWorker ?? 10,
73
+ maxConcurrentPerWorker: options.maxConcurrentPerWorker ?? 1,
67
74
  onWorkerReady: options.onWorkerReady,
68
75
  onReplacementWorkerReady: options.onReplacementWorkerReady,
69
76
  };
70
77
  }
78
+ async send(message, timeoutMs, signal, requestId) {
79
+ if (this.isDisposed) {
80
+ throw new BridgeDisposedError('Transport has been disposed');
81
+ }
82
+ if (!this.isReady) {
83
+ await this.init();
84
+ }
85
+ return this.withWorker(worker => worker.transport.send(message, timeoutMs, signal, requestId));
86
+ }
87
+ capabilities() {
88
+ this.cachedCapabilities ??= this.options.createTransport().capabilities();
89
+ return this.cachedCapabilities;
90
+ }
71
91
  // ===========================================================================
72
92
  // LIFECYCLE
73
93
  // ===========================================================================
74
94
  /**
75
- * Initialize the pooled transport.
95
+ * Initialize the pool.
76
96
  *
77
- * Creates and initializes the internal TransportPool.
78
- * If minWorkers > 0, workers are pre-spawned during init.
97
+ * If minWorkers > 0, pre-spawns workers during initialization.
98
+ * Otherwise, workers are created lazily on demand.
79
99
  */
80
100
  async doInit() {
81
- this.pool = new TransportPool({
82
- createTransport: this.poolOptions.createTransport,
83
- maxWorkers: this.poolOptions.maxWorkers,
84
- minWorkers: this.poolOptions.minWorkers,
85
- queueTimeoutMs: this.poolOptions.queueTimeoutMs,
86
- maxConcurrentPerWorker: this.poolOptions.maxConcurrentPerWorker,
87
- onWorkerReady: this.poolOptions.onWorkerReady,
88
- onReplacementWorkerReady: this.poolOptions.onReplacementWorkerReady,
89
- });
90
- await this.pool.init();
101
+ // Pre-spawn minimum workers if configured
102
+ await this.fillToMinimumWorkers();
91
103
  }
92
104
  /**
93
- * Dispose the pooled transport.
105
+ * Dispose the pool and all workers.
94
106
  *
95
- * Disposes the internal TransportPool, which disposes all workers.
107
+ * - Rejects all waiters in the queue
108
+ * - Disposes all transport instances
109
+ * - Clears internal state
96
110
  */
97
111
  async doDispose() {
98
- if (this.pool) {
99
- await this.pool.dispose();
100
- this.pool = undefined;
112
+ // Reject all waiters in the queue
113
+ for (const waiter of this.waitQueue) {
114
+ clearTimeout(waiter.timer);
115
+ waiter.reject(new BridgeExecutionError('Pool disposed'));
116
+ }
117
+ this.waitQueue.length = 0;
118
+ // Dispose all workers
119
+ const errors = [];
120
+ for (const worker of this.workers) {
121
+ try {
122
+ await worker.transport.dispose();
123
+ }
124
+ catch (e) {
125
+ errors.push(e instanceof Error ? e : new Error(String(e)));
126
+ }
127
+ }
128
+ this.workers.length = 0;
129
+ // Report errors if any
130
+ if (errors.length === 1) {
131
+ throw errors[0];
132
+ }
133
+ if (errors.length > 1) {
134
+ throw new AggregateError(errors, 'Multiple errors during worker disposal');
101
135
  }
102
136
  }
103
137
  // ===========================================================================
104
- // TRANSPORT INTERFACE
138
+ // WORKER MANAGEMENT
105
139
  // ===========================================================================
106
140
  /**
107
- * Send a message through a pooled worker.
141
+ * Acquire a worker from the pool.
108
142
  *
109
143
  * This method:
110
- * 1. Acquires a worker from the pool (waiting if necessary)
111
- * 2. Sends the message through the worker's transport
112
- * 3. Releases the worker back to the pool
144
+ * - Returns an available worker if one exists (inFlightCount < maxConcurrentPerWorker)
145
+ * - Creates a new worker if under the maxWorkers limit
146
+ * - Waits in queue if all workers are at capacity
113
147
  *
114
- * @param message - The JSON-encoded protocol message
115
- * @param timeoutMs - Timeout in milliseconds (0 = no timeout)
116
- * @param signal - Optional AbortSignal for cancellation
117
- * @returns The raw JSON response string
148
+ * @returns Promise resolving to a pooled worker
149
+ * @throws BridgeTimeoutError if queue timeout expires
150
+ * @throws BridgeExecutionError if pool is disposed while waiting
151
+ */
152
+ async acquire() {
153
+ // Check for disposed state
154
+ if (this.isDisposed || this.state === 'disposing') {
155
+ throw new BridgeExecutionError('Pool has been disposed');
156
+ }
157
+ // Find an available worker (one with capacity)
158
+ const availableWorker = this.findAvailableWorker();
159
+ if (availableWorker) {
160
+ availableWorker.inFlightCount++;
161
+ return availableWorker;
162
+ }
163
+ // Create a new worker if under the limit
164
+ // Include pendingCreations to prevent race condition where multiple
165
+ // concurrent acquire() calls all pass the length check before any
166
+ // worker is actually added to the array
167
+ if (this.workers.length + this.pendingCreations < this.options.maxWorkers) {
168
+ this.pendingCreations++;
169
+ try {
170
+ const newWorker = await this.createWorker();
171
+ if (this.isShuttingDown()) {
172
+ this.removeWorker(newWorker);
173
+ throw new BridgeExecutionError('Pool has been disposed');
174
+ }
175
+ newWorker.inFlightCount++;
176
+ this.publishAvailableWorker(newWorker);
177
+ return newWorker;
178
+ }
179
+ finally {
180
+ this.pendingCreations--;
181
+ }
182
+ }
183
+ // All workers at capacity - wait in queue
184
+ return this.waitForWorker();
185
+ }
186
+ /**
187
+ * Release a worker back to the pool.
188
+ *
189
+ * Decrements the worker's in-flight count and notifies any waiters
190
+ * that a worker may be available.
118
191
  *
119
- * @throws BridgeDisposedError if transport is disposed
120
- * @throws BridgeTimeoutError if queue timeout or request timeout expires
192
+ * @param worker - The worker to release
121
193
  */
122
- async send(message, timeoutMs, signal) {
123
- if (this.isDisposed || !this.pool) {
124
- throw new BridgeDisposedError('Transport has been disposed');
194
+ release(worker) {
195
+ // Validate the worker belongs to this pool
196
+ if (!this.workers.includes(worker)) {
197
+ return;
125
198
  }
126
- return this.pool.withWorker(async (worker) => {
127
- return worker.transport.send(message, timeoutMs, signal);
128
- });
199
+ // Decrement in-flight count (minimum 0)
200
+ worker.inFlightCount = Math.max(0, worker.inFlightCount - 1);
201
+ this.publishAvailableWorker(worker);
129
202
  }
130
203
  /**
131
- * Static capability descriptor for the pool.
204
+ * Execute a function with an acquired worker, automatically releasing afterward.
205
+ *
206
+ * This is the recommended way to use the pool, as it ensures proper cleanup
207
+ * even if the function throws an error.
132
208
  *
133
- * A pool's wire behavior is exactly that of the workers it distributes across,
134
- * so this reads the descriptor from one probe transport built by the same
135
- * factory. `createTransport` MUST be construction-side-effect-free — the
136
- * built-in transports spawn nothing until `init()`/`send()`. The result is
137
- * memoized so at most one probe is ever built regardless of call count, and
138
- * this stays safe to call at any lifecycle point.
209
+ * @param fn - Async function to execute with the worker
210
+ * @returns Promise resolving to the function's return value
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * const result = await pool.withWorker(async (worker) => {
215
+ * return worker.transport.send(message, timeout);
216
+ * });
217
+ * ```
139
218
  */
140
- capabilities() {
141
- this.cachedCapabilities ??= this.poolOptions.createTransport().capabilities();
142
- return this.cachedCapabilities;
219
+ async withWorker(fn) {
220
+ const worker = await this.acquire();
221
+ let workerRemoved = false;
222
+ try {
223
+ return await fn(worker);
224
+ }
225
+ catch (error) {
226
+ // If this is a fatal error indicating the worker is dead, remove it from the pool
227
+ if (this.isFatalWorkerError(error)) {
228
+ this.removeWorker(worker);
229
+ workerRemoved = true;
230
+ }
231
+ throw error;
232
+ }
233
+ finally {
234
+ // Only release if worker wasn't removed due to fatal error
235
+ if (!workerRemoved) {
236
+ this.release(worker);
237
+ }
238
+ }
239
+ }
240
+ // ===========================================================================
241
+ // WORKER HEALTH
242
+ // ===========================================================================
243
+ /**
244
+ * Check if an error indicates the worker is dead and should be removed.
245
+ *
246
+ * Fatal errors include:
247
+ * - Process not running
248
+ * - Process exited unexpectedly
249
+ * - Pipe errors (EPIPE)
250
+ * - Connection reset errors (ECONNRESET)
251
+ */
252
+ isFatalWorkerError(error) {
253
+ if (error instanceof BridgeProtocolError) {
254
+ const msg = error.message.toLowerCase();
255
+ return (msg.includes('not running') ||
256
+ msg.includes('process exited') ||
257
+ msg.includes('epipe') ||
258
+ msg.includes('econnreset'));
259
+ }
260
+ return false;
261
+ }
262
+ /**
263
+ * Remove a worker from the pool.
264
+ *
265
+ * This is called when a worker is detected as dead (crashed, pipe error, etc.).
266
+ * The worker's transport is disposed in the background.
267
+ */
268
+ removeWorker(worker) {
269
+ const index = this.workers.indexOf(worker);
270
+ if (index !== -1) {
271
+ this.workers.splice(index, 1);
272
+ // Dispose transport in background - don't await to avoid blocking
273
+ worker.transport.dispose().catch(() => {
274
+ // Ignore disposal errors for dead workers
275
+ });
276
+ if (this.state === 'ready') {
277
+ this.scheduleReplacementWorker();
278
+ }
279
+ }
143
280
  }
144
281
  // ===========================================================================
145
282
  // POOL STATISTICS
@@ -148,19 +285,149 @@ export class PooledTransport extends DisposableBase {
148
285
  * Current number of workers in the pool.
149
286
  */
150
287
  get workerCount() {
151
- return this.pool?.workerCount ?? 0;
288
+ return this.workers.length;
152
289
  }
153
290
  /**
154
291
  * Number of callers waiting in the queue.
155
292
  */
156
293
  get queueLength() {
157
- return this.pool?.queueLength ?? 0;
294
+ return this.waitQueue.length;
158
295
  }
159
296
  /**
160
297
  * Total number of in-flight requests across all workers.
161
298
  */
162
299
  get totalInFlight() {
163
- return this.pool?.totalInFlight ?? 0;
300
+ return this.workers.reduce((sum, w) => sum + w.inFlightCount, 0);
301
+ }
302
+ // ===========================================================================
303
+ // PRIVATE HELPERS
304
+ // ===========================================================================
305
+ /**
306
+ * Find an available worker with capacity for another request.
307
+ */
308
+ findAvailableWorker() {
309
+ return this.workers.find(w => w.inFlightCount < this.options.maxConcurrentPerWorker);
310
+ }
311
+ getMinimumWorkerDeficit() {
312
+ return Math.max(0, this.options.minWorkers - (this.workers.length + this.pendingCreations));
313
+ }
314
+ isShuttingDown() {
315
+ return this.isDisposed || this.state === 'disposing';
316
+ }
317
+ async fillToMinimumWorkers() {
318
+ await this.spawnWorkers(this.getMinimumWorkerDeficit());
319
+ }
320
+ async spawnWorkers(count) {
321
+ if (count === 0) {
322
+ return;
323
+ }
324
+ this.pendingCreations += count;
325
+ try {
326
+ await Promise.all(Array.from({ length: count }, () => this.spawnWorkerToPool()));
327
+ }
328
+ finally {
329
+ this.pendingCreations = Math.max(0, this.pendingCreations - count);
330
+ }
331
+ }
332
+ /**
333
+ * Replace a removed worker in the background so the next caller does not pay
334
+ * the full worker cold-start penalty after a timeout or crash.
335
+ */
336
+ scheduleReplacementWorker() {
337
+ if (this.state !== 'ready') {
338
+ return;
339
+ }
340
+ if (this.workers.length + this.pendingCreations >= this.options.maxWorkers) {
341
+ return;
342
+ }
343
+ this.pendingCreations++;
344
+ const replacementReady = this.options.onReplacementWorkerReady ?? this.options.onWorkerReady;
345
+ this.spawnWorkerToPool(replacementReady)
346
+ .catch(() => {
347
+ // Ignore background replacement failures. A later acquire() can retry.
348
+ })
349
+ .finally(() => {
350
+ this.pendingCreations = Math.max(0, this.pendingCreations - 1);
351
+ });
352
+ }
353
+ async spawnWorkerToPool(onWorkerReady = this.options.onWorkerReady) {
354
+ if (this.isShuttingDown()) {
355
+ return;
356
+ }
357
+ const worker = await this.createWorker(onWorkerReady);
358
+ if (this.isShuttingDown()) {
359
+ this.removeWorker(worker);
360
+ return;
361
+ }
362
+ this.publishAvailableWorker(worker);
363
+ }
364
+ publishAvailableWorker(worker) {
365
+ while (this.waitQueue.length > 0 &&
366
+ worker.inFlightCount < this.options.maxConcurrentPerWorker) {
367
+ const waiter = this.waitQueue.shift();
368
+ if (!waiter) {
369
+ return;
370
+ }
371
+ clearTimeout(waiter.timer);
372
+ worker.inFlightCount++;
373
+ waiter.resolve(worker);
374
+ }
375
+ }
376
+ /**
377
+ * Create a new worker and add it to the pool.
378
+ *
379
+ * If onWorkerReady is configured, calls it after the transport is initialized.
380
+ * This is useful for per-worker warmup (importing modules, running setup).
381
+ */
382
+ async createWorker(onWorkerReady = this.options.onWorkerReady) {
383
+ const transport = this.options.createTransport();
384
+ // Initialize the transport
385
+ await transport.init();
386
+ const worker = {
387
+ transport,
388
+ inFlightCount: 0,
389
+ };
390
+ try {
391
+ // Call onWorkerReady callback if provided
392
+ if (onWorkerReady) {
393
+ await onWorkerReady(worker);
394
+ }
395
+ }
396
+ catch (error) {
397
+ // Ensure partially initialized workers do not leak when warmup fails.
398
+ await transport.dispose().catch(() => {
399
+ // Ignore disposal failures during warmup failure handling.
400
+ });
401
+ throw error;
402
+ }
403
+ if (this.state === 'disposing' || this.state === 'disposed') {
404
+ await transport.dispose().catch(() => {
405
+ // Ignore disposal failures if the pool was torn down mid-creation.
406
+ });
407
+ throw new BridgeExecutionError('Pool disposed during worker creation');
408
+ }
409
+ this.workers.push(worker);
410
+ return worker;
411
+ }
412
+ /**
413
+ * Wait in queue for a worker to become available.
414
+ */
415
+ waitForWorker() {
416
+ return new Promise((resolve, reject) => {
417
+ const timer = setTimeout(() => {
418
+ // Remove this waiter from the queue
419
+ const index = this.waitQueue.findIndex(w => w.timer === timer);
420
+ if (index !== -1) {
421
+ this.waitQueue.splice(index, 1);
422
+ }
423
+ reject(new BridgeTimeoutError(`Timed out waiting for available worker after ${this.options.queueTimeoutMs}ms`));
424
+ }, this.options.queueTimeoutMs);
425
+ // Unref the timer so it doesn't keep the Node.js process alive
426
+ if (typeof timer.unref === 'function') {
427
+ timer.unref();
428
+ }
429
+ this.waitQueue.push({ resolve, reject, timer });
430
+ });
164
431
  }
165
432
  }
166
433
  //# sourceMappingURL=pooled-transport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pooled-transport.js","sourceRoot":"","sources":["../../src/runtime/pooled-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,aAAa,EAAuB,MAAM,qBAAqB,CAAC;AA2CzE,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,eAAgB,SAAQ,cAAc;IAChC,WAAW,CAM1B;IACM,IAAI,CAAiB;IAC7B,sFAAsF;IAC9E,kBAAkB,CAAyB;IAEnD;;;;OAIG;IACH,YAAY,OAA+B;QACzC,KAAK,EAAE,CAAC;QAER,IAAI,OAAO,OAAO,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;YAClD,MAAM,IAAI,oBAAoB,CAAC,oCAAoC,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,CAAC,WAAW,GAAG;YACjB,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC;YACnC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC;YACnC,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,KAAK;YAC/C,sBAA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AK,EAAC,MAAM,EAAC,EAAE;YACzC,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,YAAY;QACV,IAAI,CAAC,kBAAkB,KAAK,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,YAAY,EAAE,CAAC;QAC9E,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED,8EAA8E;IAC9E,kBAAkB;IAClB,8EAA8E;IAE9E;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,IAAI,EAAE,WAAW,IAAI,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,IAAI,EAAE,WAAW,IAAI,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,EAAE,aAAa,IAAI,CAAC,CAAC;IACvC,CAAC;CACF"}
1
+ {"version":3,"file":"pooled-transport.js","sourceRoot":"","sources":["../../src/runtime/pooled-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAiErB,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,eAAgB,SAAQ,cAAc;IAChC,OAAO,CAMtB;IACe,OAAO,GAAqB,EAAE,CAAC;IAC/B,SAAS,GAAmB,EAAE,CAAC;IAChD,0EAA0E;IAClE,gBAAgB,GAAG,CAAC,CAAC;IACrB,kBAAkB,CAAyB;IAEnD;;;;OAIG;IACH,YAAY,OAA+B;Q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,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;gBAC/D,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;oBACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBAClC,CAAC;gBACD,MAAM,CACJ,IAAI,kBAAkB,CACpB,gDAAgD,IAAI,CAAC,OAAO,CAAC,cAAc,IAAI,CAChF,CACF,CAAC;YACJ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YAEhC,+DAA+D;YAC/D,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;gBACtC,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,CAAC;YAED,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"pyodide-bootstrap-core.generated.d.ts","sourceRoot":"","sources":["../../src/runtime/pyodide-bootstrap-core.generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAO,MAAM,0BAA0B,EAAE,MAAkn5C,CAAC"}
1
+ {"version":3,"file":"pyodide-bootstrap-core.generated.d.ts","sourceRoot":"","sources":["../../src/runtime/pyodide-bootstrap-core.generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAO,MAAM,0BAA0B,EAAE,MAAm42C,CAAC"}