plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.27k stars 2.05k forks source link

Dash app shows "Updating..." forever #1028

Open slishak opened 4 years ago

slishak commented 4 years ago

Describe your context Since updating from Dash 1.4.1 to 1.5.0, one of my apps has been displaying Updating... in the title forever on page load even though all callbacks have completed. I finally managed to create a minimum reproducible example!

dash                 1.6.1
dash-core-components 1.5.1
dash-html-components 1.0.2
dash-renderer        1.2.1
dash-table           4.5.1
- OS: Windows 10
- Browser: Chrome and Edge

Describe the bug

App continues displaying Updating... in the title despite no callback still running

Expected behavior

Title should become Dash after all callbacks are complete

Example code

Run the code below then navigate to http://127.0.0.1:6060/main

import dash

import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Output, Input, State

APP = dash.Dash(__name__)
APP.config.suppress_callback_exceptions = True

INDEX_PAGE = html.Div(
    dcc.Link('main', refresh=True, href='/main')
)

MAIN_LAYOUT = html.Div([
    html.Button('Button 1', id='b1', style={'background-color': 'lightsalmon'}),
    dcc.Dropdown(id='dd1', multi=True),
    dcc.Dropdown(id='dd2', multi=True, value=[]),
    dcc.Graph(id='test')
])

APP.layout = html.Div([
    dcc.Location(id='url', refresh=True),
    html.Div(id='page-content'),
])

@APP.callback(
    Output('page-content', 'children'),
    [Input('url', 'pathname')]
)
def display_page(pathname):
    if pathname == '/main':
        return MAIN_LAYOUT

    if pathname == '/':
        return INDEX_PAGE

    return 404

@APP.callback(
    Output('dd1', 'options'),
    [Input('dd2', 'value')]
)
def dd1_opts(dd2_val):
    return []

@APP.callback(
    Output('dd1', 'value'),
    [Input('dd2', 'value')]
)
def dd1_val(dd2_val):
    return []

@APP.callback(
    Output('b1', 'style'),
    [Input('dd1', 'value')]
)
def style_button(val):
    return {}

if __name__ == '__main__':
    APP.run_server(port=6060, threaded=False)
alexcjohnson commented 4 years ago

Thanks for the concrete example @slishak - confirmed, and I suspect this is related to #1008

slishak commented 4 years ago

This specific test case doesn't seem to reproduce the bug in Dash 1.7.0. However upgrading Dash does not fix the significantly more complicated app that this example is based on.

It's alternatively fixed by putting a dcc.Graph component in the initial app.layout as hinted at in https://github.com/plotly/dash/issues/1010, as looking in the network graph it did seem to be related to an async js load. This method does fix the actual app.