MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / constructor

Method constructor

src/extraction/parse-pool.ts:244–268  ·  view source on GitHub ↗
(opts: ParseWorkerPoolOptions)

Source from the content-addressed store, hash-verified

242 private readonly grammarBuffers?: Record<string, Uint8Array>;
243
244 constructor(opts: ParseWorkerPoolOptions) {
245 this.languages = opts.languages;
246 this.grammarBuffers = opts.grammarBuffers;
247 this.maxSize = Math.max(1, Math.min(opts.size, MAX_PARSE_POOL_SIZE));
248 this.expectedParses = opts.expectedParses;
249 this.recycleInterval = opts.recycleInterval ?? DEFAULT_RECYCLE_INTERVAL;
250 this.parseTimeoutMs = opts.parseTimeoutMs ?? DEFAULT_PARSE_TIMEOUT_MS;
251 this.loadSettleMs = opts.loadSettleMs ?? GRAMMAR_LOAD_SETTLE_MS;
252 this.log = opts.log ?? (() => {});
253 if (opts.createWorker) {
254 this.createWorker = opts.createWorker;
255 } else if (opts.workerScriptPath) {
256 const scriptPath = opts.workerScriptPath;
257 // Deliberately no `resourceLimits.stackSizeMb`: a bigger worker stack
258 // only moves the cliff a deeply nested file falls off (#1581 — the
259 // 8 MiB main thread still dies at 100k levels). The native kernel
260 // guards its own recursion against THIS thread's real stack bounds
261 // (codegraph-kernel/src/stack.rs) and defers such a file to the wasm
262 // path, which catches its JS RangeError per file.
263 this.createWorker = () => new Worker(scriptPath);
264 } else {
265 throw new Error('ParseWorkerPool requires workerScriptPath or createWorker');
266 }
267 this.spawnOne(); // one eager warm worker, ready for the first parse
268 }
269
270 /**
271 * Spawn the pool up front, as far as the run is worth it. The default

Callers

nothing calls this directly

Calls 1

spawnOneMethod · 0.95

Tested by

no test coverage detected