OpenClinica / enketo-oc

OpenClinica's fork of the Enketo web forms monorepo
Apache License 2.0
0 stars 1 forks source link

In headless mode return error response immediately when a caught loading error occurs #98

Open MartijnR opened 2 years ago

MartijnR commented 2 years ago

E.g in headless mode, a form that has a calculation that is run upon load and includes a non-existing XPath function.

Or, an instance to be loaded is not available. Or clinical data file is not available.

Return 400?

MartijnR commented 2 years ago

calc syntax error:

curl --user enketorules: -d "server_url=http://localhost:3000&form_id=fails&instance=\
    <data><calc1/><meta><instanceID>a</instanceID></meta></data>&instance_id=a&ecid=b" http://localhost:8005/oc/api/v1/instance/headless

baseline: 1,715 | 1,599 | 1,555 ms, after:

I don't think there is scope to improve this for this scenario.

record not available:

Since record is passed in the API request, I don't think this scenario is realistic.

external instance not available:

curl --user enketorules: -d "server_url=http://localhost:3000&form_id=dn-calculate&instance=\
    <dn-calculate><a>1</a><meta><instanceID>a</instanceID></meta></dn-calculate>&instance_id=a&ecid=b" http://localhost:8005/oc/api/v1/instance/headless

baseline: 31,152 | 31,107 | 31,150, after: 1,412 | 1,373 | 1,356

This scenario may only be temporary but there will be similar scenarios with an exception that is not properly caught. What is happening in this scenario is that the app waits until the 30 second timeout has passed. Use http://localhost:8005/single/fs/i/uEUZO5H2?ecid=b for development.

MartijnR commented 2 years ago

If an exception occurs before the form is initalized (e.g. atm for a missing external data file), the response will now be up to 30 seconds faster (usually close to 30 seconds).

pbowen-oc commented 2 years ago

@MartijnR - Is there a change for this in the latest master branch?

MartijnR commented 2 years ago

Oops, it looks like I forgot to push that. It is done now (to master) but for some reason the commit is not yet shown in this thread.