-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] PlotlyJSONEncoder cannot serialize dash.dash._NoUpdate responses; throws TypeError #1014
Comments
Thanks @ProbonoBonobo - can you post an example callback that shows this behavior? This works fine for me: app.layout = html.Div([
dcc.Input(id='x'),
html.P('aaaaa', id='a'),
html.P('bbbbb', id='b'),
html.P('ccccc', id='c')
])
@app.callback(
[Output('a', 'children'), Output('b', 'children'), Output('c', 'children')],
[Input('x', 'value')]
)
def f(x):
return x, dash.no_update, (x or '') + 'c' The |
My hunch is that this error emerges in combination with flask-caching, in particular the case where the return value of a callback function is memoized. This hunch is supported by my observations that the error presents only when observed properties are modified in quick succession. When those requests are received at lengthier intervals than the cache timeout, I see no such errors. But I will want to confirm that with a minimal reproducible example first. Will try to make one ASAP. |
Yep, it's related to
For this example I'm using the filesystem instead of redis to make the code easier to run, but the caching backend makes no difference (I can confirm it happens with redis too). The error relates to the Commenting out the |
Oh, one more important detail I didn't realize until just now: I'm initializing the application server with |
Ah OK, I guess that makes sense - when Line 1360 in 5d9f578
and here: Line 1370 in 5d9f578
We should be able to just replace those checks by Thanks for the help debugging this! |
fix #1014 - test for no_update by type rather than identity
Hi, I'm new on Dash and sorry if I'm using this comment in a inappropriate way. But, I'm experimenting this error in my app, since I'd upgraded the dash version from 1.9.3 to 1.12.0. My callback return just contain value, options and data (dcc.store) property types. So, is the bug solved in that last version? If not, is there a workaround in the meantime? Thanks. |
Hi, EDIT: It seems that this error was actually caused by (unintentionally) returning a 'dict_keys' object one of multiple Outputs, where other Outputs include dash.no_update. However, although the 'dict_keys' object appears to have been the culprit, the exception was the same as the one in this issue, i.e. This was very confusing! Any idea why this would happen? |
@JonThom I don't know offhand why |
Hi JonaThan, i can't remember exactly what i did, but I worked around the problem by doing a refactor of my app, including a dash upgrade. Sorry if I couldn't help you out more. It's been a while since the last time i worked on that code. |
Environment:
Not sure if it's related to the issue I was trying to diagnose, but I noticed the following error printed repeatedly to my console while investigating why my application spends longer (~8x longer) awaiting 204 (No Content) responses than 200 (OK) ones:
Before filing this as a bug, I considered a possibility that this might be expected behavior. If a
_NoUpdate
object means the client state is already correct, it might make sense to crash and burn on the encoding, catch the TypeError, and return a 204 response header immediately.But I'm pretty sure this is just a boring, garden-variety serialization bug, because (as I understand it) it's perfectly alright to sandwich
_NoUpdate
values between actual data in the return value of a multi-output callback. So I would expectPlotlyJSONEncoder
to have a mechanism for serializing those objects.The text was updated successfully, but these errors were encountered: