| 2590 | } |
| 2591 | |
| 2592 | private async runProjectForkExclusive<T>(projectPath: string, fn: () => Promise<T>): Promise<T> { |
| 2593 | assert(projectPath.length > 0, "runProjectForkExclusive requires projectPath"); |
| 2594 | |
| 2595 | const previousLaunch = |
| 2596 | this.reservedTaskLaunchByProjectPath.get(projectPath) ?? Promise.resolve(); |
| 2597 | const run = previousLaunch.catch(() => undefined).then(fn); |
| 2598 | const trackedLaunch = run |
| 2599 | .then( |
| 2600 | () => undefined, |
| 2601 | () => undefined |
| 2602 | ) |
| 2603 | .finally(() => { |
| 2604 | if (this.reservedTaskLaunchByProjectPath.get(projectPath) === trackedLaunch) { |
| 2605 | this.reservedTaskLaunchByProjectPath.delete(projectPath); |
| 2606 | } |
| 2607 | }); |
| 2608 | this.reservedTaskLaunchByProjectPath.set(projectPath, trackedLaunch); |
| 2609 | return await run; |
| 2610 | } |
| 2611 | |
| 2612 | private async materializeReservedTaskWorkspace( |
| 2613 | plan: TaskLaunchPlan, |