* Serialize all disk writes per workspace so clear() and appendToFile() * can never complete out of order.
(workspaceId: string, fn: () => Promise<void>)
| 565 | * can never complete out of order. |
| 566 | */ |
| 567 | private enqueueWrite(workspaceId: string, fn: () => Promise<void>): Promise<void> { |
| 568 | const prev = this.writeQueues.get(workspaceId) ?? Promise.resolve(); |
| 569 | // Always chain regardless of prior failure so the queue never stalls. |
| 570 | const next = prev.then(fn, () => fn()); |
| 571 | this.writeQueues.set(workspaceId, next); |
| 572 | return next; |
| 573 | } |
| 574 | |
| 575 | private async appendToFile(workspaceId: string, entry: DevToolsLogEntry): Promise<void> { |
| 576 | return this.enqueueWrite(workspaceId, async () => { |
no test coverage detected