Ensure that we always enqueue in the same order received
This commit is contained in:
parent
1d7987108b
commit
baf419b7b6
1 changed files with 6 additions and 1 deletions
|
@ -138,6 +138,8 @@ MessageReceiver.prototype.extend({
|
||||||
},
|
},
|
||||||
handleRequest(request) {
|
handleRequest(request) {
|
||||||
this.incoming = this.incoming || [];
|
this.incoming = this.incoming || [];
|
||||||
|
const lastPromise = _.last(this.incoming);
|
||||||
|
|
||||||
// We do the message decryption here, instead of in the ordered pending queue,
|
// We do the message decryption here, instead of in the ordered pending queue,
|
||||||
// to avoid exposing the time it took us to process messages through the time-to-ack.
|
// to avoid exposing the time it took us to process messages through the time-to-ack.
|
||||||
|
|
||||||
|
@ -165,8 +167,11 @@ MessageReceiver.prototype.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.addToCache(envelope, plaintext).then(
|
return this.addToCache(envelope, plaintext).then(
|
||||||
() => {
|
async () => {
|
||||||
request.respond(200, 'OK');
|
request.respond(200, 'OK');
|
||||||
|
|
||||||
|
// To ensure that we queue in the same order we receive messages
|
||||||
|
await lastPromise;
|
||||||
this.queueEnvelope(envelope);
|
this.queueEnvelope(envelope);
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue