Duplicate callback outputs with identical inputs (and potentially different states) fail
Open
@T4rk1n is already working on this.
Since Jul 25, 2024.
bug
P3
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Environment
dash 2.9.2
Describe the bug
When 2 callbacks are created with a duplicate output (and allow_duplicate=True) and the same Inputs (States can be different), Dash gives a Duplicate callback outputs error.
from dash import Input, Output, Patch, State, callback
@callback(
Output("deck", "data", allow_duplicate=True),
Input("filter1", "value"),
Input("filter2", "value"),
State("state1", "value),
prevent_initial_call=True,
)
def add_layer1(filter1, vilter2, state1):
layer1 = load_layer1(filter1, vilter2, state1)
update = Patch()
update.layers[0] = layer1
return update
@callback(
Output("deck", "data", allow_duplicate=True),
Input("filter1", "value"),
Input("filter2", "value"),
State("state2", "value),
prevent_initial_call=True,
)
def add_layer2(filter1, vilter2, state2):
layer2 = load_layer2(filter1, vilter2, state2)
update = Patch()
update.layers[1] = layer2
return update
Expected behavior
This should either:
- work, the use case is to load the data in several chunks / layers and return it with
Patchso that things start displaying on the screen sooner - or give a descriptive error message (something like "Several callbacks with duplicate Outputs have identical Inputs")
I assume that this is due to a hashing that is done based on the Inputs only, maybe it could include the decorated function name and the States in the hash as well?
Current workaround: Adding a dummy Input in the callback saves the day.
Screenshots

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.