mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Set isInTransaction to false even if close throws
If a transaction wrapper's closer throws (such as flushBatchedUpdates in ReactDefaultBatchingStrategy) then we still want to properly deinitialize the transaction by setting isInTransaction to false. Without this, we can't reuse the transaction object (in this case, all future batched updates would fail because nested transactions aren't allowed).
This commit is contained in:
1 parent
7aaa3a4ed1
commit
17f602f924
2 files changed
+14
-10
No files matched your search
+13
-10
@@ -161,19 +161,22 @@ var Mixin = {
|
||||
} finally {
|
||||
var memberEnd = Date.now();
|
||||
this.methodInvocationTime += (memberEnd - memberStart);
|
||||
if (errorThrown) {
|
||||
// If `method` throws, prefer to show that stack trace over any thrown
|
||||
// by invoking `closeAll`.
|
||||
try {
|
||||
try {
|
||||
if (errorThrown) {
|
||||
// If `method` throws, prefer to show that stack trace over any thrown
|
||||
// by invoking `closeAll`.
|
||||
try {
|
||||
this.closeAll(0);
|
||||
} catch (err) {
|
||||
}
|
||||
} else {
|
||||
// Since `method` didn't throw, we don't want to silence the exception
|
||||
// here.
|
||||
this.closeAll(0);
|
||||
} catch (err) {
|
||||
}
|
||||
} else {
|
||||
// Since `method` didn't throw, we don't want to silence the exception
|
||||
// here.
|
||||
this.closeAll(0);
|
||||
} finally {
|
||||
this._isInTransaction = false;
|
||||
}
|
||||
this._isInTransaction = false;
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
||||
@@ -243,6 +243,7 @@ describe('Transaction', function() {
|
||||
expect(function() {
|
||||
transaction.perform(function() {});
|
||||
}).toThrow(exceptionMsg);
|
||||
expect(transaction.isInTransaction()).toBe(false);
|
||||
});
|
||||
|
||||
it('should allow nesting of transactions', function() {
|
||||
|
||||
Reference in new issue
Block a user