plotly/dash

[BUG] Recurrent werkzeug (utf-8) error in Lambda AWS.

Opened this issue ยท 5 comments

Thank you so much for helping improve the quality of Dash!

We do our best to catch bugs during the release process, but we rely on your help to find the ones that slip through.

Describe your context

You can deploy Flask apps in AWS Lambda. From my understanding, Dash should be available with small changes. However, I'm hitting a werkzeug error (utf-8 decode). I have tried with different (and minimal) apps, in different computers (all MacOS). Those apps work fine in local and Heroku.
I also tried to deploy Dash inside a Flask app within Lambda. Flask app works fine but Dash fails (again, it works fine locally and in Heroku).

  • replace the result of pip list | grep dash below
dash-core-components==1.9.1
dash-html-components==1.0.3
dash==1.11.0

This specific intent is with zappa==0.51.0, although i tried many combinations across zappa and dash

  • if frontend related, tell us your Browser, Version and OS

    • OS: [e.g. iOS]
    • Browser [e.g. chrome, safari]
    • Version [e.g. 22]

Describe the bug

This is the error message I get:

"{'message': 'An uncaught exception happened while servicing this request. You can investigate this with the `zappa tail` command.', 'traceback': ['Traceback (most recent call last):\\n', '  File \"/var/task/handler.py\", line 558, in handler\\n    zappa_returndict[\\'body\\'] = response.get_data(as_text=True)\\n', '  File \"/var/task/werkzeug/wrappers/base_response.py\", line 340, in get_data\\n    rv = rv.decode(self.charset)\\n', \"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte\\n\"]}"

Sometimes the error prevent the lambda function from being deployed. Sometimes is deployed and the error is found later. But the error always hit the same place.

If you need more context please let me know. I don't have a deep knowledge of the internals or werkzeug within Dash and Flask and the differences in their behavior.

Code:
app.py

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash(__name__, requests_pathname_prefix = '/dev/')

app.layout = html.Div('Error example')
server = app.server

zappa_settings.json

{
    "dev": {
        "app_function": "app.server",
        "profile_name": "default",
        "project_name": "dash-error",
        "runtime": "python3.6",
        "s3_bucket": "mys3bucket"
    }
}

Expected behavior

Show the Dash APP in Lambda directly or within a Flask App

Screenshots

If applicable, add screenshots or screen recording to help explain your problem.

Any updates on this. I'm also going through with the same issue

I have the same problem with Zappa and Flask, migrated werkzeug to 0.16.0 did not help.
EDIT: Maybe somebody will find this post in the future, in my case downgrade of zappa helped

I have the same problem with Zappa and Flask, migrated werkzeug to 0.16.0 did not help.
EDIT: Maybe somebody will find this post in the future, in my case downgrade of zappa helped

Which zappa version do you use? I tried a bunch and I always hit the same issue.

It would be very useful If you post here your pip freeze (at least for zappa, werkzeug and the multiple dash libraries).

Thanks!

lv10 commented

I was able to solve the issue using zappa==0.50.0.

I was able to solve the issue using zappa==0.50.0.

Then you can't use docker any more.