Skip to content

Commit 0a4b2e0

Browse files
committed
fix: remove explicit transaction commit on drop
For some reason, calling `TransactionSys::do_commit` in the `Drop` implementation of `Transaction` causes tests in a headless Chrome browser to hang, even though they pass in a non-headless context. Ultimately, the default behavior on the JavaScript end is for the transaction to be committed, so it is safe to exclude this action.
1 parent 200d0b2 commit 0a4b2e0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/transaction.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ impl Drop for Transaction<'_> {
162162
fn drop(&mut self) {
163163
self.listeners.free_listeners();
164164

165-
if !self.done {
166-
let _ = match self.on_drop {
167-
OnTransactionDrop::Abort => self.as_sys().abort(),
168-
OnTransactionDrop::Commit => self.as_sys().do_commit(),
169-
};
165+
// Given that the default behavior in JavaScript is to commit the
166+
// transaction when it is dropped, we only need to perform an action
167+
// when we want to abort the transaction.
168+
if !self.done & matches!(self.on_drop, OnTransactionDrop::Abort) {
169+
let _ = self.as_sys().abort();
170170
}
171171
}
172172
}

0 commit comments

Comments
 (0)