# Progress message freezes on error when triggered by downloadbutton

**URL:** <https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547>\
**Category:** Bug & Error Reports\
**Created:** [3 August 2022 06:16 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547 "2022-08-03T06:16:02Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wichard](https://community.viktor.ai/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@Wichard](https://community.viktor.ai/u/Wichard)\
**Post date:** [3 August 2022 06:16 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/1 "2022-08-03T06:16:02Z")

</div>

## Which SDK and Platform version are you using?

SDK: v13.2.1  
Platform: v22.06.4

## Current Behavior

During a lengthy calculation triggered by an Downloadbutton exceptions don’t seem to be caught by the progressmessage: the progressmessage freezes and the cancel button is not working. I have to refresh the page to get out.

The weird thing: when I trigger the same calculation by a slow view the exception is caught as expected and I can close the pop up as excpeted.  
…

## Expected Behavior

Same behaviour as at the slow view  
…

---

<div class="post-metadata">

**Author:** ![khameeteman](https://community.viktor.ai/user_avatar/community.viktor.ai/khameeteman/32/51_2.png) [@khameeteman](https://community.viktor.ai/u/khameeteman)\
**Post date:** [3 August 2022 09:06 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/2 "2022-08-03T09:06:47Z")

</div>

Hi Wichard,

Is this a constant issue or does it occur randomly? Do you perhaps have a minimal code example to help us reproduce the issue?

---

<div class="post-metadata">

**Author:** ![Wichard](https://community.viktor.ai/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@Wichard](https://community.viktor.ai/u/Wichard)\
**Post date:** [3 August 2022 09:16 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/3 "2022-08-03T09:16:30Z")

</div>

It seems a constant issue: Not sure if a code snippet is helpful but here it is.

```python
    @WebView("SCIA results Energy Equilibrium", duration_guess=5)
    def visualize_scia_results_iterative_calculation(self, params, entity_id, **kwargs):

        try:
            scia_model = pickle.loads(Storage().get("scia_model", scope="entity").getvalue_binary())
            results = pickle.loads(Storage().get("intermediate_results", scope="entity").getvalue_binary())

        except FileNotFoundError:
            _, updated_scia_file, scia_model, results = self.scia_optimize_energy_absorption(params)
            Storage().set("final_iteration_model", data=File.from_data(updated_scia_file.getvalue()), scope="entity")
            Storage().set("scia_model", data=File.from_data(pickle.dumps(scia_model)), scope="entity")
            Storage().set("intermediate_results", data=File.from_data(pickle.dumps(results)), scope="entity")

        plotly_figure = create_plotly_iterative_energy_calculation_results(scia_model, results, params)

    def download_scia_model_after_iterations(self, params, entity_name, **kwargs):
        try:
            updated_scia_model = Storage().get("final_iteration_model", scope="entity")
        except FileNotFoundError:
            _, updated_scia_model, scia_model, results = self.scia_optimize_energy_absorption(params)
            Storage().set("final_iteration_model", data=File.from_data(updated_scia_model.getvalue()), scope="entity")
            Storage().set("scia_model", data=File.from_data(pickle.dumps(scia_model)), scope="entity")
            Storage().set("intermediate_results", data=File.from_data(pickle.dumps(results)), scope="entity")

        return DownloadResult(
            updated_scia_model,
            file_name=f"{entity_name}_ESA_model_final_iteration.esa",
        )

```

---

<div class="post-metadata">

**Author:** ![khameeteman](https://community.viktor.ai/user_avatar/community.viktor.ai/khameeteman/32/51_2.png) [@khameeteman](https://community.viktor.ai/u/khameeteman)\
**Post date:** [3 August 2022 10:45 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/4 "2022-08-03T10:45:15Z")

</div>

Could you exaplain a bit what is happening in `scia_optimize_energy_absorption`, I assume you are raising the UserException over there?

How long does the method take approximately?

(How often) do you send a progress message + percentage?

---

<div class="post-metadata">

**Author:** ![Wichard](https://community.viktor.ai/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@Wichard](https://community.viktor.ai/u/Wichard)\
**Post date:** [3 August 2022 11:20 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/5 "2022-08-03T11:20:45Z")

</div>

in scia\_optimize\_energy\_absorptioin a iterative scia calculation is started. The method is lenghty, somewhere between 3 and 20 minutes depending on the number of loops.

De progress message + percentage is updated every loop (so every 3 minutes?). De weird thing is (as you can see) when triggered by a slow view: it works (same method). when triggered by a button the error is not caught en the screen freezes.

The UserException I tested is even before the iterative calculation starts → the input parameters are checked before the loop starts, (and before I initated a usermessage)

---

<div class="post-metadata">

**Author:** ![kvangiessen](https://community.viktor.ai/user_avatar/community.viktor.ai/kvangiessen/32/14_2.png) [@kvangiessen](https://community.viktor.ai/u/kvangiessen)\
**Post date:** [3 August 2022 13:23 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/6 "2022-08-03T13:23:40Z")

</div>

Hi Wichard,

Could you show the Parametrization side of this as well? We have sometimes seen weird behaviour where there was a mismatch between the button-type (e.g. DownloadButton/SetParamsButton) and the result type on the controller (e.g. DownloadResult, etc.).

---

<div class="post-metadata">

**Author:** ![Wichard](https://community.viktor.ai/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@Wichard](https://community.viktor.ai/u/Wichard)\
**Post date:** [3 August 2022 13:31 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/7 "2022-08-03T13:31:44Z")

</div>

```python
    scia = Page("SCIA", views=["visualize_scia_results_iterative_calculation"])
    scia.downloads = Section("Downloads")
    scia.downloads.input_xml_btn = DownloadButton("Input .xml +.def", method="download_scia_input_xml")
    scia.downloads.esa = DownloadButton("SCIA model: single run", method="download_scia_model_esa")
    scia.downloads.new_line = LineBreak()
    scia.downloads.esa_energy_optimalisation = DownloadButton(
        "SCIA model: iterative", method="download_scia_model_after_iterations"
    )

```

---

<div class="post-metadata">

**Author:** ![khameeteman](https://community.viktor.ai/user_avatar/community.viktor.ai/khameeteman/32/51_2.png) [@khameeteman](https://community.viktor.ai/u/khameeteman)\
**Post date:** [3 August 2022 14:01 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/8 "2022-08-03T14:01:45Z")

</div>

Does the issue occur in development and / or production?

---

<div class="post-metadata">

**Author:** ![Wichard](https://community.viktor.ai/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@Wichard](https://community.viktor.ai/u/Wichard)\
**Post date:** [3 August 2022 14:04 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/9 "2022-08-03T14:04:48Z")

</div>

In development, I haven’t checkt production yet

---

<div class="post-metadata">

**Author:** ![khameeteman](https://community.viktor.ai/user_avatar/community.viktor.ai/khameeteman/32/51_2.png) [@khameeteman](https://community.viktor.ai/u/khameeteman)\
**Post date:** [3 August 2022 14:06 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/10 "2022-08-03T14:06:15Z")

</div>

Are you running on venv or docker isolation?

---

<div class="post-metadata">

**Author:** ![Wichard](https://community.viktor.ai/letter_avatar_proxy/v4/letter/w/7bcc69/32.png) [@Wichard](https://community.viktor.ai/u/Wichard)\
**Post date:** [3 August 2022 14:07 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/11 "2022-08-03T14:07:52Z")

</div>

I’m running in on venv

---

<div class="post-metadata">

**Author:** ![khameeteman](https://community.viktor.ai/user_avatar/community.viktor.ai/khameeteman/32/51_2.png) [@khameeteman](https://community.viktor.ai/u/khameeteman)\
**Post date:** [3 August 2022 14:33 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/12 "2022-08-03T14:33:03Z")

</div>

I will send you a DM

---

<div class="post-metadata">

**Author:** ![khameeteman](https://community.viktor.ai/user_avatar/community.viktor.ai/khameeteman/32/51_2.png) [@khameeteman](https://community.viktor.ai/u/khameeteman)\
**Post date:** [4 August 2022 14:10 UTC](https://community.viktor.ai/t/progress-message-freezes-on-error-when-triggered-by-downloadbutton/547/13 "2022-08-04T14:10:16Z")

</div>

This issue is caused by a connector version which we have now downgraded.

In case anyone experiences the same issue, please reinstall the app!
