1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Set event error before emitting

So the event object properties are in a consistent state when we
the event is emitted.

Fixes first part of https://github.com/vector-im/riot-web/issues/5936
This commit is contained in:
David Baker
2018-01-09 13:23:04 +00:00
parent af4f05c29e
commit 4946c5e687

View File

@@ -1136,8 +1136,11 @@ function _sendEvent(client, room, event, callback) {
console.error("Error sending event", err.stack || err);
try {
_updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
// set the error on the event before we update the status:
// updating the status emits the event, so the state should be
// consistent at that point.
event.error = err;
_updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
// also put the event object on the error: the caller will need this
// to resend or cancel the event
err.event = event;