Dash-update-component doesn't work well is there Flask problem or Dash issue?

Hi everybody,

I’ve created a customized react component to visualize a special chart(invention for a client), then i use it in the dash app.

This component asks an array of dictionaries, then visualizes the desired chart.

In some cases, the flask argues to send the response to the client side, but when you check in the browser there are no responses and the page is always in loading.

in the react js code, the component works well and I test it and it doesn’t matter.

Now the question is why does Flask serve responses partially, it sends json files to the browser and there is no js file to elaborate the data?

I look forward to hearing from you.

1 Like

Hello @mohsenhaddadi,

Have you tried running it in debug mode?

Thanks for your prompt answer.

Yes, nothing error, here i send the call back an other codes i use.
Of course i skip all the codes.

def fetch_radiant_data(client):
    return get_products(config, client)


layout = html.Div([
    dbc.Spinner(
        [
            dcc.Loading(
                id='radiant-chart-loading',
                children=[
                    html.Div(id='radiant-chart-content')
                ]
            )
        ],
        color="primary",
        type="grow",
        id="loading-spinner",
    )
])

def get_radiant_chart(client, products_data):
    try:
        return html.Div(
            style={'display': 'flex', 'justifyContent': 'center'},
            children=[
                rcc.CitsComponent(
                    size=1000,
                    id='cits-'+client.replace(' ', '-'),
                    title='Radiant Chart',
                    domains=domains,
                    arcs=arcs,
                    products=products_data
                ),
            ],
        )
    except Exception as e:
        print(f"Error in get_radiant_chart for client {client}: {e}")
        return html.Div("Error in rendering the Radiant Chart.")


@app.callback(
    Output('radiant-chart-content', 'children'),
    Input('tabs-example-graph', 'value'),
)
    def render_radiant_chart(tab):
        if 'radiant' in tab:
            client = tab
            products_data = fetch_radiant_data(client)
            return get_radiant_chart(client, products_data)
        else:
            raise PreventUpdate```


When the code passes from ```return get_radiant_chart(client, products_data)```
always in loading nothing to show in the browser.

But in some cases are OK, some of them no. there is no response from flask!!!!

However in all time the react js visualize the chart perfectly.

Thanks.

Hmm, try it with debug false.

It sounds like something isnt working on the server side.

The problem is the same with debug=False :melting_face:

The problem will still be the same, but with debug false, the errors are not passed back to the client but remain on the server in the console.

I understood now, but i don’t see nothing error on the server in the console yet.

Without seeing more of your code, its really hard to say what is the issue…

Could it be possible that the request is just not being sent?

When i try to switch to the chart tab i see the request are sent

[2024-02-02 19:17:55 +0100] [68648] [DEBUG] POST /_dash-update-component
[2024-02-02 19:17:55 +0100] [68635] [DEBUG] POST /_dash-update-component
[2024-02-02 19:17:55 +0100] [68648] [DEBUG] POST /_dash-update-component

I set some prints in my functions, then i see there are results from print after above loggs.

Hmm, ok, is your function not working right?

All functions are working, there are results where i put print

Then idk, its hard to know without more code, or seeing your component.