Skip to content

Commit 72880da

Browse files
committed
Updated to kwargs strategy
1 parent 9c8b796 commit 72880da

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5050

5151
### Bug fixes
5252

53+
* Fixed issue where apps run in Workbench were unexpectedly crashing. Apps in Workbench will now have `ws_per_message_deflate=False` enforced. (#2005)
54+
5355
* Fixed an issue where the `<main>` areas of `ui.page_sidebar()` and `ui.page_navbar()` (with a `sidebar`) were made to be a fillable containers even when `fillable=False`. (#1816)
5456

5557
* Fixed an issue where the `.update_user_input()` method on `ui.Chat()` isn't working in shinylive. (#1891)

shiny/_main.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from .bookmark._bookmark_state import shiny_bookmarks_folder_name
2626
from .express import is_express_app
2727
from .express._utils import escape_to_var_name
28+
from ._hostenv import is_workbench
29+
import warnings
2830

2931

3032
@click.group("main")
@@ -334,11 +336,6 @@ def run_app(
334336

335337
# Workaround for nginx/uvicorn issue within Workbench
336338
# https://github.com/rstudio/rstudio-pro/issues/7368#issuecomment-2918016088
337-
deflate_args: DeflateArgs = {}
338-
if is_workbench():
339-
deflate_args = {
340-
"ws_per_message_deflate": False,
341-
}
342339

343340
if reload_dirs is None:
344341
reload_dirs = []
@@ -408,6 +405,17 @@ def run_app(
408405

409406
maybe_setup_rsw_proxying(log_config)
410407

408+
if is_workbench() and kwargs.get("ws_per_message_deflate"):
409+
# Workaround for nginx/uvicorn issue within Workbench
410+
# https://github.com/rstudio/rstudio-pro/issues/7368#issuecomment-2918016088
411+
warnings.warn(
412+
"Overwriting kwarg 'ws_per_message_deflate'=True to False to avoid breaking issue in Workbench",
413+
stacklevel=2,
414+
)
415+
kwargs["ws_per_message_deflate"] = False
416+
elif is_workbench():
417+
kwargs["ws_per_message_deflate"] = False
418+
411419
uvicorn.run( # pyright: ignore[reportUnknownMemberType]
412420
app,
413421
host=host,
@@ -421,7 +429,6 @@ def run_app(
421429
# Don't allow shiny to use uvloop!
422430
# https://github.com/posit-dev/py-shiny/issues/1373
423431
loop="asyncio",
424-
**deflate_args, # pyright: ignore[reportArgumentType]
425432
**reload_args, # pyright: ignore[reportArgumentType]
426433
**kwargs,
427434
)
@@ -723,10 +730,6 @@ class ReloadArgs(TypedDict):
723730
reload_dirs: NotRequired[list[str]]
724731

725732

726-
class DeflateArgs(TypedDict):
727-
ws_per_message_deflate: NotRequired[bool]
728-
729-
730733
# Check that the version of rsconnect supports Shiny Express; can be removed in the
731734
# future once this version of rsconnect is widely used. The dependency on "packaging"
732735
# can also be removed then, because it is only used here. (Added 2024-03)

0 commit comments

Comments
 (0)