(w: ParsePoolWorker, job: ParseJob)
| 264 | } |
| 265 | |
| 266 | private dispatch(w: ParsePoolWorker, job: ParseJob): void { |
| 267 | this.inflight.set(w, job); |
| 268 | this.parseCounts.set(w, (this.parseCounts.get(w) ?? 0) + 1); |
| 269 | // Scale the timeout for large files: base + 10s per 100KB (matches the |
| 270 | // original single-worker formula so pathological-file behaviour is unchanged). |
| 271 | const timeoutMs = this.parseTimeoutMs + Math.floor(job.task.content.length / 100_000) * 10_000; |
| 272 | job.timer = setTimeout(() => this.onTimeout(w, job, timeoutMs), timeoutMs); |
| 273 | job.timer.unref?.(); |
| 274 | w.postMessage({ |
| 275 | type: 'parse', |
| 276 | id: job.id, |
| 277 | filePath: job.task.filePath, |
| 278 | content: job.task.content, |
| 279 | frameworkNames: job.task.frameworkNames, |
| 280 | language: job.task.language, |
| 281 | }); |
| 282 | } |
| 283 | |
| 284 | private onTimeout(w: ParsePoolWorker, job: ParseJob, ms: number): void { |
| 285 | if (job.settled || !this.workers.has(w)) return; |
no test coverage detected