Skip to content

Commit d08abba

Browse files
authored
Merge pull request #3986 from BSd3v/patch-2
Modify before-request hooks to handle results for fastapi
2 parents 0a88259 + b377434 commit d08abba

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
3232
- [#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)).
3333
- [#3948](https://github.com/plotly/dash/issues/3948) Fix page getting progressively slower as callbacks append children
3434

35+
### Changed
36+
- [#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.
37+
3538
## [4.4.1] - 2026-07-21
3639

3740
## Fixed

‎dash/backends/_fastapi.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,11 @@ async def _run_before_hooks(self) -> None:
163163
"""Run all before-request hooks."""
164164
for func in self.before_request_funcs:
165165
if inspect.iscoroutinefunction(func):
166-
await func()
166+
result = await func()
167167
else:
168-
func()
168+
result = func()
169+
if result is not None:
170+
return result
169171

170172
async def _run_after_hooks(self) -> None:
171173
"""Run after-request hook if configured."""

0 commit comments

Comments
 (0)