Skip to content

Commit

Permalink
fix(jstz_proto): handle tx correctly in Script.run
Browse files Browse the repository at this point in the history
  • Loading branch information
ryutamago committed Feb 3, 2025
1 parent f8ae950 commit 4a11f1a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions crates/jstz_proto/src/executor/smart_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,13 @@ impl Script {
result,
|value, _context| {
runtime::with_js_hrt_and_tx(|hrt, tx| -> JsResult<()> {
let response = Response::try_from_js(value)?;

// If status code is 2xx, commit transaction
if response.ok() {
tx.commit(hrt)?;
} else {
tx.rollback()?;
}
match Response::try_from_js(value) {
// commit if the value returned is a response with a 2xx status code
Ok(response) if response.ok() => {
tx.commit(hrt)?;
}
_ => tx.rollback()?,
};

Ok(())
})
Expand Down

0 comments on commit 4a11f1a

Please sign in to comment.