Pass abortSignal to sendToGroup
This commit is contained in:
parent
7afe3fcca2
commit
3be95e821e
6 changed files with 49 additions and 26 deletions
|
@ -3440,7 +3440,10 @@ export class ConversationModel extends window.Backbone
|
|||
return null;
|
||||
}
|
||||
|
||||
queueJob<T>(name: string, callback: () => Promise<T>): Promise<T> {
|
||||
queueJob<T>(
|
||||
name: string,
|
||||
callback: (abortSignal: AbortSignal) => Promise<T>
|
||||
): Promise<T> {
|
||||
this.jobQueue = this.jobQueue || new window.PQueue({ concurrency: 1 });
|
||||
|
||||
const taskWithTimeout = createTaskWithTimeout(
|
||||
|
@ -3448,6 +3451,9 @@ export class ConversationModel extends window.Backbone
|
|||
`conversation ${this.idForLogging()}`
|
||||
);
|
||||
|
||||
const abortController = new AbortController();
|
||||
const { signal: abortSignal } = abortController;
|
||||
|
||||
const queuedAt = Date.now();
|
||||
return this.jobQueue.add(async () => {
|
||||
const startedAt = Date.now();
|
||||
|
@ -3458,7 +3464,10 @@ export class ConversationModel extends window.Backbone
|
|||
}
|
||||
|
||||
try {
|
||||
return await taskWithTimeout();
|
||||
return await taskWithTimeout(abortSignal);
|
||||
} catch (error) {
|
||||
abortController.abort();
|
||||
throw error;
|
||||
} finally {
|
||||
const duration = Date.now() - startedAt;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue