Skip to content

Commit 12a3f1c

Browse files
committed
Wrap update function in try block.
1 parent 1dc4911 commit 12a3f1c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/modules/database/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,17 @@ export default class Database extends Base {
174174

175175
_handleDatabaseTransaction(event) {
176176
const {id, originalValue} = event;
177-
const updateCallback = this.transactions[id];
178-
const newValue = updateCallback(originalValue);
179-
let abort = false;
180-
if (newValue === undefined) {
181-
abort = true;
177+
let newValue;
178+
try {
179+
const updateCallback = this.transactions[id];
180+
newValue = updateCallback(originalValue);
181+
} finally {
182+
let abort = false;
183+
if (newValue === undefined) {
184+
abort = true;
185+
}
186+
FirestackDatabase.tryCommitTransaction(id, {value: newValue}, abort);
182187
}
183-
FirestackDatabase.tryCommitTransaction(id, {value: newValue}, abort);
184188
}
185189

186190
/**

0 commit comments

Comments
 (0)