fix: await queued Pi worker suspension
This commit is contained in:
@@ -657,10 +657,18 @@ export class PiWorkerPool {
|
||||
}
|
||||
|
||||
private async ensureFresh(record: WorkerRecord): Promise<WorkerRecord> {
|
||||
const current = this.workers.get(record.conversation.conversationId);
|
||||
const conversationId = record.conversation.conversationId;
|
||||
let current = this.workers.get(conversationId);
|
||||
if (!current) throw new Error('Conversation worker is no longer available');
|
||||
if (current !== record) return await this.ensureFresh(current);
|
||||
if (record.rebuildFlight) return await record.rebuildFlight;
|
||||
if (record.processStopFlight) {
|
||||
await record.processStopFlight;
|
||||
current = this.workers.get(conversationId);
|
||||
if (!current) throw new Error('Conversation worker is no longer available');
|
||||
if (current !== record) return await this.ensureFresh(current);
|
||||
if (record.rebuildFlight) return await record.rebuildFlight;
|
||||
}
|
||||
if (!record.processLease) {
|
||||
record.rebuildFlight = this.beginRebuild(record, this.revisions.current);
|
||||
return await record.rebuildFlight;
|
||||
|
||||
Reference in New Issue
Block a user