dash icon indicating copy to clipboard operation
dash copied to clipboard

`prevent_initial_call="initial_duplicate"` not working as expected

Open Lxstr opened this issue 1 year ago • 1 comments

Hello!

dash==2.17.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-mantine-components==0.14.4

Describe the bug I have callbacks I wish to start on load (prevent_initial_call=False) and do not care about the order of results eg. loading data and then sending dmc notification.

These are either from the same page or different pages targeting the same output. Having the ability to send from different pages helps the consistency app as the user sees notifications persist between pages.

Setting prevent_initial_call="initial_duplicate" and allow_duplicate=True results in effectively prevent_initial_Call=True. If only set to on some of the duplicate results in the following error, which says to do the thing I am already doing.

dash.exceptions.DuplicateCallback: allow_duplicate requires prevent_initial_call to be True. The order of the call is not guaranteed to be the same on every page load. To enable duplicate callback with initial call, set prevent_initial_call='initial_duplicate' or globally in the config prevent_initial_callbacks='initial_duplicate'

I also tried setting this at the global level but results in:

TypeError: Dash() got an unexpected keyword argument 'prevent_initial_callback' Perhaps I am misunderstanding the purpose but I just want to run the callbacks with full awareness that the order is not guaranteed (desirable in this case).

The only documentation I could find is https://community.plotly.com/t/dash-2-9-2-released-partial-property-updates-with-patch-duplicate-outputs-dcc-geolocation-scatter-group-attributes-and-more/72114#allowing-duplicate-callback-outputs-7

I've attached an MRE here https://github.com/Lxstr/dash-multi-page-app-demos/tree/prevent-initial-duplicate

Thanks!

Lxstr avatar Sep 03 '24 11:09 Lxstr

A workaround is to change @callback to @app.callback

andre996 avatar Aug 19 '25 23:08 andre996