Skip to content

Commit

Permalink
Make the AS pending transaction promise propagate errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sandhose committed Dec 15, 2023
1 parent e268005 commit d95e54d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/appservice/Appservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class Appservice extends EventEmitter {
private appServer: any;
private intentsCache: LRU.LRUCache<string, Intent>;
private eventProcessors: { [eventType: string]: IPreprocessor[] } = {};
private pendingTransactions: { [txnId: string]: Promise<any> } = {};
private pendingTransactions: { [txnId: string]: Promise<void> } = {};

/**
* Creates a new application service.
Expand Down Expand Up @@ -695,8 +695,7 @@ export class Appservice extends EventEmitter {
}

LogService.info("Appservice", "Processing transaction " + txnId);
// eslint-disable-next-line no-async-promise-executor
this.pendingTransactions[txnId] = new Promise<void>(async (resolve) => {
this.pendingTransactions[txnId] = Promise.resolve((async () => {
// Process all the crypto stuff first to ensure that future transactions (if not this one)
// will decrypt successfully. We start with EDUs because we need structures to put counts
// and such into in a later stage, and EDUs are independent of crypto.
Expand Down Expand Up @@ -891,9 +890,7 @@ export class Appservice extends EventEmitter {
this.emit("room.upgraded", event['room_id'], event);
}
}

resolve();
});
})());

try {
await this.pendingTransactions[txnId];
Expand Down

0 comments on commit d95e54d

Please sign in to comment.