Using `return`, `break` or `throw` to exit a transaction block is deprecated without replacement
View options
- Truncate descriptions
DEPRECATION WARNING: Using `return`, `break` or `throw` to exit a transaction block is deprecated without replacement. If the `throw` came from `Timeout.timeout(duration)`, pass an exception class as a second argument so it doesn't use `throw` to abort its block. This results in the transaction being committed, but in the next release of Rails it will rollback. (called from public_send at /srv/gitlab/lib/gitlab/database/load_balancing/connection_proxy.rb:127)
-- https://log.gprd.gitlab.net/goto/437032f0-ecac-11ed-a017-0d32180b1390
This seems to have been introduced recently
Refactoring
In order to avoid break
(and return
) in Model.transaction
blocks one could:
-
1️⃣ Usenext
to commit a transaction andraise
to rollback -
2️⃣ Extract code into methods and use guards (early return) instead -
3️⃣ : Refactor/restructure related conditionals in the block
🆕 👮 Rails/TransactionExitStatement
We can enable
- Show labels
- Show closed items
Link items together to show that they're related or that one is blocking others.