Skip to content

[BUG] Callback with canceled update intermittently prevents later callback #1053

@alexcjohnson

Description

@alexcjohnson

If I make a callback chain where a final output depends on an input via multiple paths, a PreventUpdate on one of those paths can intermittently prevent the final callback from ever firing.

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

app = dash.Dash(__name__)
app.layout = html.Div([
    dcc.Input(id='a', value="x"),
    html.Div('b', id='b'),
    html.Div('c', id='c'),
    html.Div(id='out')
])

@app.callback(
    Output("out", "children"),
    [Input("a", "value"), Input("b", "children"), Input("c", "children")]
)
def set_out(a, b, c):
    print("out")
    return "{}/{}/{}".format(a, b, c)

@app.callback(Output("b", "children"), [Input("a", "value")])
def set_b(a):
    print("b")
    raise PreventUpdate

@app.callback(Output("c", "children"), [Input("a", "value")])
def set_c(a):
    print("c")
    return a

if __name__ == "__main__":
    app.run_server(debug=True)

Both on initial load and later as you type in the input box, sometimes you'll see the last line correctly concatenating the three lines before it, sometimes it lags behind. I don't notice a pattern, this happens anywhere from about a quarter to three quarters of the time.

I'll try to sort this out along with wildcards #475

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions