From c9e23cc38abc96fd0bfa3f8a3d3a42045ec372d9 Mon Sep 17 00:00:00 2001 From: philippe Date: Fri, 10 Apr 2026 11:35:42 -0400 Subject: [PATCH 1/2] fix fastapi websocket --- dash/backends/_fastapi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dash/backends/_fastapi.py b/dash/backends/_fastapi.py index 4e6266146f..edb5bade27 100644 --- a/dash/backends/_fastapi.py +++ b/dash/backends/_fastapi.py @@ -188,6 +188,7 @@ async def _handle_error( async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: # Handle lifespan events (startup/shutdown) + if scope["type"] == "lifespan": try: dash_app = get_app() @@ -199,7 +200,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: return # Non-HTTP/WebSocket scopes pass through - if scope["type"] not in ("http", "websocket"): + if scope["type"] != "http": await self.app(scope, receive, send) return From 0af47f130417c0d3310ea545ef43dc1ae1c9f8e9 Mon Sep 17 00:00:00 2001 From: philippe Date: Fri, 10 Apr 2026 11:38:19 -0400 Subject: [PATCH 2/2] remove leftover prints --- dash/backends/_fastapi.py | 5 ----- dash/dash.py | 1 - 2 files changed, 6 deletions(-) diff --git a/dash/backends/_fastapi.py b/dash/backends/_fastapi.py index edb5bade27..4e5bdad621 100644 --- a/dash/backends/_fastapi.py +++ b/dash/backends/_fastapi.py @@ -299,7 +299,6 @@ def setup_catchall(self, dash_app: Dash): def _setup_catchall(self): try: - print("Setting up catch-all route for unmatched paths", file=sys.stderr) dash_app = get_app() async def catchall(_request: Request): @@ -318,10 +317,6 @@ def add_url_rule( methods: list[str] | None = None, include_in_schema: bool = False, ): - print( - f"Adding URL rule: {rule} -> {view_func} (endpoint: {endpoint}, methods: {methods})", - file=sys.stderr, - ) if rule == "": rule = "/" if isinstance(view_func, str): diff --git a/dash/dash.py b/dash/dash.py index d17c3c4e4e..ea53edf341 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -637,7 +637,6 @@ def __init__( # pylint: disable=too-many-statements, too-many-branches self._got_first_request = {"pages": False, "setup_server": False} if server: - print(f"init app from server {server}") self.init_app() self.logger.setLevel(logging.INFO)