orbeon / orbeon-forms

Orbeon Forms is an open source web forms solution. It includes an XForms engine, the Form Builder web-based form editor, and the Form Runner runtime.
http://www.orbeon.com/
GNU Lesser General Public License v2.1
511 stars 220 forks source link

`fr:run-process-by-name()` isn't sync anymore #6342

Closed avernet closed 1 month ago

avernet commented 1 month ago

What brought our attention to this was that when publishing from Form Builder, we used to save then publish, but now saving happens in parallel to publishing. This is done in builder/form/model.xml. When we get the fb-publish-form event, first fr:run-process-by-name('oxf.fr.detail.process', 'save') runs, then <xf:send submission="fb-publish-submission">. These two operations run in parallel because fr:run-process-by-name() is now asynchronous.

Instead of running the save process directly, we considered running another process that runs save then dispatches an event back to the model. When we get that event, we would run <xf:send submission="fb-publish-submission">. The problem is that we need context. We could save it in an instance, as we don't expect multiple publish operations to run concurrently, but this adds complexity.

We would also need to do something similar in other places (and there may be more):

I'd like to avoid adding complexity in multiple places, making the code more error-prone and harder to maintain:

+1 from customer

ebruchez commented 1 month ago

We discussed a few options:

The last option is the one we are following. But for this to work, we need to change the implementation of runProcess()to return a Future or IO.

def runProcess(
    scope:      String,
    process:    String,
    initialTry: Try[Any] = Success(())
): Either[Try[Any], IO[Any]]

This in turn means making changes to the AsynchronousSubmissionManager.