Skip to content

Issue 1424 - Latest flask-compress (1.6.0) breaks Dash #1426

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

Merged
merged 9 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## Unreleased
### Fixed
- [#1426](https://github.com/plotly/dash/pull/1426) Fix a regression caused by `flask-compress==1.6.0` causing performance degradation on server requests

## [1.16.2] - 2020-09-25
### Fixed
- [#1415](https://github.com/plotly/dash/pull/1415) Fix a regression with some layouts callbacks involving dcc.Tabs, not yet loaded dash_table.DataTable and dcc.Graph to not be called
Expand Down
13 changes: 13 additions & 0 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import flask
from flask_compress import Compress
from werkzeug.debug.tbtools import get_current_traceback
from pkg_resources import get_distribution, parse_version

import plotly
import dash_renderer
Expand Down Expand Up @@ -49,6 +50,8 @@
from . import _validate
from . import _watch

_flask_compress_version = parse_version(get_distribution("flask-compress").version)

# Add explicit mapping for map files
mimetypes.add_type("application/json", ".map", True)

Expand Down Expand Up @@ -283,6 +286,16 @@ def __init__(
else:
raise ValueError("server must be a Flask app or a boolean")

if (
self.server is not None
and not hasattr(self.server.config, "COMPRESS_ALGORITHM")
and _flask_compress_version >= parse_version("1.6.0")
):
# flask-compress==1.6.0 changed default to ['br', 'gzip']
# and non-overridable default compression with Brotli is
# causing performance issues
self.server.config["COMPRESS_ALGORITHM"] = ["gzip"]

base_prefix, routes_prefix, requests_prefix = pathname_configs(
url_base_pathname, routes_pathname_prefix, requests_pathname_prefix
)
Expand Down
2 changes: 1 addition & 1 deletion requires-install.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Flask>=1.0.2
flask-compress==1.5.0
flask-compress
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfix flask-compress

plotly
dash_renderer==1.8.2
dash-core-components==1.12.1
Expand Down