(w: ParsePoolWorker, job: ParseJob)
| 340 | } |
| 341 | |
| 342 | private dispatch(w: ParsePoolWorker, job: ParseJob): void { |
| 343 | this.inflight.set(w, job); |
| 344 | this.parseCounts.set(w, (this.parseCounts.get(w) ?? 0) + 1); |
| 345 | // Scale the timeout for large files: base + 10s per 100KB (matches the |
| 346 | // original single-worker formula so pathological-file behaviour is unchanged). |
| 347 | const timeoutMs = this.parseTimeoutMs + Math.floor(job.task.content.length / 100_000) * 10_000; |
| 348 | job.budgetMs = timeoutMs; |
| 349 | job.timer = setTimeout(() => this.onTimeout(w, job, timeoutMs), timeoutMs); |
| 350 | job.timer.unref?.(); |
| 351 | w.postMessage({ |
| 352 | type: 'parse', |
| 353 | id: job.id, |
| 354 | filePath: job.task.filePath, |
| 355 | content: job.task.content, |
| 356 | frameworkNames: job.task.frameworkNames, |
| 357 | language: job.task.language, |
| 358 | }); |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * The base timer fired with no result processed yet. Do NOT kill or settle: |
no test coverage detected