Internal server error

This will be hard for me to describe but…
Im performing UMAP in my application but on new devices it crashes with the message:
“Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR)”
And it refers to : “dash-update-component:1”.

I have timeout set to 600000 on all related callbacks, I also use:

import diskcache
from dash.long_callback import DiskcacheLongCallbackManager

cache = diskcache.Cache("./cache")
long_callback_manager = DiskcacheLongCallbackManager(cache)

To prevent timeouts. I also blocked umap from using all cpu cores (i read that could be an issue where it consumes the core that hosted the server).

But now to the tricky part. If i keep trying it will keep crashing… until suddenly it just works? Then after that one time it works, it will continue to work until i clear the cache in my VSC. I use the same input every time, printing it to make sure that umap is recieving what it needs to run. In addition I have wrapped the code with try-except in the sensitive places and printing the error that could arise… but no error shows in my IDE, only in the frontend (the error i referred to in the start of this thread).

I probably left a lot out that people need to help with this but please just ask and I will try to fill you in.

Here is another issue that also happends sometimes when i run the above, where it does not complain on Internal server error. The image is from inspecting the network traffic (Chrome).

full error text for the below:
Error: Callback failed: the server did not respond.

at handleError (http://127.0.0.1:8050/_dash-component-suites/dash/dash-renderer/build/dash_renderer.v2_14_2m1732095032.dev.js:870:14)

Hello @JD222SD,

It’s possible that your app is crashing and restarting? Or just erroring out somehow…

Anyways, you should use on_error for your app so you can see issues like this. Also, you should make sure you are using the latest version. long_callback_manager isnt really updated. XD

Should just be DiskcacheManager and background_callback_manager = DiskcacheManager(cache)

Yeah it crashes and restarts after one of those two errors occuring. But only for that one callback.

on_error seems interesting, never heard of but will definitely look it up!

Regarding long_callback_manager I had no Idea haha, just searched and find that one and it was suggested as a solution, but I will check the other one and try it out, thank you!

Now i’ve tried this:

Putting it as an arg to dash.register page creates no complaint (image), but of what I can see when i enter the library there is no “on_error” there either?

Also the background_callback_manager did not help either. I dont think this is a timeout error, rather a very confusing error… Since it suddenly works sometimes untill I clear the cache and voilá, the error is back

You should be using the latest version of dash. You’re probably on an earlier version.

Was just going to update my reply, sorry for that hehe!

I get no on_error trigger when it crashes even now with 2.18.

Im going crazy over this, how can nothing I do trigger any kind of error message besides the useless one i get in the browser

Can’t help much more without seeing code.

Can you create a minimum reproducible example?

I understand. Now it works (as it does randomly sometimes).

Unsure if I can create a minimum example since this is a part of a pipeline that uses csv inputs etc.

but basically it crashes during the fit_transform (Running UMAP fit… is printed but never Done with UMAP").

def _umap(self, n_components=2, n_neighbors=15, min_dist=0.1, metric='euclidean'):
    """Uniform Manifold Approximation and Projection (UMAP)."""

    print("Running UMAP...")
    try:
        model = UMAP(
            n_components=n_components,
            n_neighbors=n_neighbors,
            min_dist=min_dist,
            metric=metric,
        )
    except Exception as e:
        print("Error in creation of UMAP object:", e)
        return None
    try:
        print("Running UMAP fit...")
        result = model.fit_transform(self.X)
        print("Done with UMAP fit", result)
    except Exception as e:
        print("Error occured in UMAP fit:", e)
        return None
    return result

the inputs for this huge merged callback are:

@dash.callback(
[
Output(“dr-transformed-data”, “data”), # Store computed DR data
Output(“dr-x-dropdown”, “options”),
Output(“dr-x-dropdown”, “value”),
Output(“dr-x-dropdown”, “style”),
Output(“dr-y-dropdown”, “options”),
Output(“dr-y-dropdown”, “value”),
Output(“dr-y-dropdown”, “style”),
Output(“dr-z-dropdown”, “options”),
Output(“dr-z-dropdown”, “value”),
Output(“dr-z-dropdown”, “style”),
Output(“dr-dimension”, “options”),
Output(“dr-dimension”, “value”),
Output(“dr-dimension”, “style”),
Output(“dr-plot”, “figure”),
],
[
Input(“compute-dr-btn”, “n_clicks”), # Trigger DR computation
Input(“dr-x-dropdown”, “value”), # Selected x-axis
Input(“dr-y-dropdown”, “value”), # Selected y-axis
Input(“dr-z-dropdown”, “value”), # Selected z-axis
Input(“dr-dimension”, “value”), # 2D/3D switch
Input(“feature-relevance-graph”, “clickData”),
# a click on the feature relevance graph
],
[
State(“target-variable-dropdown”, “value”), # Target variable for coloring
State(“dr-methods-dropdown”, “value”), # DR method
State(
{“type”: “dr-param-input”, “method”: ALL, “param”: ALL}, “value”
), # DR parameters
State(
{“type”: “dr-param-input”, “method”: ALL, “param”: ALL}, “id”
), # DR parameter IDs
State(“selected-columns-feature-relevance”, “data”), # Selected features
State(“filename-data”, “data”), # Clean data
State(“dr-transformed-data”, “data”),
],
prevent_initial_call=True,
timeout=600000,
background_callback_manager=background_callback_manager,
on_error=update_output_error_handler
)
def merged_DR_callback(

Maybe that Could be an issue? That the callback inputs/states are so many? I have no experience in Dash projects and do not know the limitations.

I use things like:

Blockquote
if triggered_id == “compute-dr-btn”:
print(“We pressed the compute-dr-btn”)
if not selected_method or not feature_relevance_selected_data or not clean_data:
raise dash.exceptions.PreventUpdate

to handle what should happen based on which input that is triggered based of

ctx = dash.callback_context
triggered_id = ctx.triggered[0]["prop_id"].split(".")[0] if ctx.triggered else None

You can split callbacks now and allow duplicates to be able to target the same output.

There shouldn’t be much of a restriction. I’d recommend getting things to a smaller working function.

Thank you very much for your help.

Regarding the bugg im experiencing It seems to be a problem when running the app in debug=True only. So maybe I can accept the fact that it is acting up in the debug version. Even if I dont like it

If it’s only happening in debug=True is it because your app is restarting? This would lead to the server not responding on a callback.

Disable hot-reloading and see if that stops the issue.

Yeah and only for one method specifically. But I’ve debugged the F out of that one and i can’t find any issue with it, especially when the error originates from javascript.

So I will just give up here. Thanks a lot for your help Jinnyzor !

1 Like