1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

Merge pull request #1357 from matrix-org/bwindels/fixwaitforeventrace

Handle race between sending and await next event from other party
This commit is contained in:
Bruno Windels
2020-04-29 13:53:35 +00:00
committed by GitHub
2 changed files with 9 additions and 0 deletions

View File

@@ -122,6 +122,11 @@ export class VerificationBase extends EventEmitter {
if (this._done) {
return Promise.reject(new Error("Verification is already done"));
}
const existingEvent = this.request.getEventFromOtherParty(type);
if (existingEvent) {
return Promise.resolve(existingEvent);
}
this._expectedEvent = type;
return new Promise((resolve, reject) => {
this._resolveEvent = resolve;