Expected Behavior: Exceptions & Transactions (Web, Reactive, Mobile)

Hi,

Imagine we have a common "Detail" screen and "Save Detail" screen action with two server actions (one to save the record and another one to do something else in the server), what happens if the second server action raises an exception. Is the record saved in the database?

Cheers,

João

Hi João,

if there is a handling exception in SaveDetail action it will follow that exception if there isn't any handling exception inside Contact_Save action. No data is saved.

Check this page to learn more about handling exceptions:

https://success.outsystems.com/Documentation/11/Developing_an_Application/Implement_Application_Logic/Handle_Exceptions/Exception_Handling_Mechanism

Regards

mvp_badge
MVP

Hi João,

If the second server action generates an exception the complete transaction also Contact_Save is rolled back.

Side note: Don't add multiple server actions in a client actions, bundle them in one server action, so that your client logic only needs one roundtrip to the server.

Regards,

Daniel


Hi everyone,

Actually, it depends! :)

I did some tests and we get two different behaviors depending on the type of app we are using.

Reactive Web and Mobile: if the second server action raises an exception, the record is saved in the database (this is another reason as Daniël Kuhlmann pointed out to only use one server action in a screen action, not only is more performant but also ensures data consistency).

Web Traditional:  if the second server action raises an exception, the record is not saved in the database (if there isn't any handling exception as José Gonçalves mentioned).

So why do we have these two different behaviors?

Here's a possible explanation*:

  • Reactive Web and Mobile: in a screen action every server action call is an independent web request:
    - so a rollback will revert only the changes made by the server action that raised the exception and not the previous server actions.

  • Web Traditional: in a screen action every server action is under a single web request:
    - so a rollback will revert all the changes made by the server action that raised the exception and also by the previous server actions*.

* Assuming there are no explicit commits along the way.

Cheers,

João

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.