Skip to content

[18.0][FIX] fastapi: pool apps by endpoint root path, not request path - #670

Open
SparkDrago05 wants to merge 1 commit into
OCA:18.0from
SparkDrago05:18.0-fix-fastapi-app-pool-root-path
Open

SparkDrago05 wants to merge 1 commit into
OCA:18.0from
SparkDrago05:18.0-fix-fastapi-app-pool-root-path

Conversation

@SparkDrago05

Copy link
Copy Markdown

Fixes #656.

The app pool was keyed on the full request path, so every distinct URL built and kept its own FastAPI app. It is now keyed on the endpoint's root path.

Tested on 18.0 with the steps from the issue (53 requests): 51 apps kept before, 1 after. A new test covers it, and the fastapi tests pass (24/24).

Assisted-by: Claude Opus 5.5

@oca-cla-bot

oca-cla-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @lmignon,
some modules you are maintaining are being modified, check this out!

@SparkDrago05

Copy link
Copy Markdown
Author

The failing test jobs are unrelated to this change: every 18.0 PR currently fails on extendable-pydantic with pydantic 2.14. #671 pins pydantic to fix CI.

@lmignon lmignon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the fix. LGTM.

Comment thread fastapi/tests/test_fastapi.py Outdated
Comment on lines +199 to +200
# Requests to different paths of an endpoint share the apps of its root
# path, instead of building one app per request path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO this comment is useless.... Here you check that call to endpoints under the same root path are processed by the same app (only one app initialized by root path)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done, thanks.

Comment thread fastapi/fastapi_dispatcher.py Outdated
Comment on lines +32 to +33
# Pool apps by the endpoint's root path, not by the request path:
# otherwise each distinct path builds and keeps its own app.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment useless... it's the the what not the why.... Here we want to ensure that only one app exists by endpoint's root path.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done, thanks.

@lmignon lmignon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you fix the comments?

FastApiDispatcher passed the full request path as the key of the app
pool. Every distinct path under an endpoint, including unknown paths
and path parameters, built and kept its own FastAPI application until
the registry cache was invalidated, so worker memory grew with the
number of distinct paths requested, even unauthenticated ones.

Resolve the endpoint's root path once per request and use it as the
pool key and for the uid lookup.

Fixes OCA#656

Assisted-by: Claude Opus 5.5
Signed-off-by: SparkDrago05 <huzaifa.farooq05@gmail.com>
@SparkDrago05
SparkDrago05 force-pushed the 18.0-fix-fastapi-app-pool-root-path branch from 0af2b57 to 6dd4696 Compare October 23, 2026 07:31
@SparkDrago05

Copy link
Copy Markdown
Author

The 19.0 forward port is in #677.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants