Web UI deployment status progress bar keeps advancing even if state script exited with 1

Hi guys.
I wrote a state script associated with the Sync Leave state, that alternatively exits with RC 0 or RC 1 based on a certain condition. My idea is to allow or block the update process through this script. As you can see in the attached image, the state transition flow seems correct by inspecting log files, however the progress bar in deployment status section of Mender Web UI keeps advancing, while indicating the execution of Sync Leave script.

Is that an intended behavior, or there’s something I’m missing? And, ultimately, is correct to use state scripts to perform such updating flow operations, or is better to use the REST API?

@andrea.nencini the progress bar in the UI is an estimate of the progress in the device, it doesn’t represent the real percentage of the progress during the device update.

Regarding your second question, if the information wether the device can perform the update is client-side, state scripts are the way to go.