diff --git a/CHANGELOG.md b/CHANGELOG.md index 51e3212852..2694a70f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,9 @@ This project adheres to [Semantic Versioning](https://semver.org/). - [#3929](https://github.com/plotly/dash/issues/3929) Fix components that set their own initial state on mount (eg. `dash-bootstrap-components` `Tabs`, which selects its default active tab) not applying that state on first render - a component's descendant layout hashes were reset on its very first fresh render, discarding the mount-time update before it took effect. The reset now only runs from the second fresh render onward, so a component's initial state survives (regression introduced in 4.2.0 by [#3570](https://github.com/plotly/dash/pull/3570)). - [#3948](https://github.com/plotly/dash/issues/3948) Fix page getting progressively slower as callbacks append children +### Changed +- [#3986](https://github.com/plotly/dash/pull/3986) Adjusted the `_run_before_hooks` inf `fastapi` backend to allow for a return value in the event that a `before_request` function returns a response. This is more aligned with how the `before_request` hooks work in the `flask` backend. + ## [4.4.1] - 2026-07-21 ## Fixed diff --git a/dash/backends/_fastapi.py b/dash/backends/_fastapi.py index e617d5f20b..daec8fbc8c 100644 --- a/dash/backends/_fastapi.py +++ b/dash/backends/_fastapi.py @@ -163,9 +163,11 @@ async def _run_before_hooks(self) -> None: """Run all before-request hooks.""" for func in self.before_request_funcs: if inspect.iscoroutinefunction(func): - await func() + result = await func() else: - func() + result = func() + if result is not None: + return result async def _run_after_hooks(self) -> None: """Run after-request hook if configured."""