From 4bfda7041d0dd52bf8509a443c945273cfe26f74 Mon Sep 17 00:00:00 2001 From: Anya-Gupta-05 Date: Mon, 25 May 2026 11:55:52 +0530 Subject: [PATCH 1/2] fix: apply timeout to mounted ASGI apps (#5246) TimeoutMiddleware was applied to native @bentoml.api routes but not to apps mounted via @bentoml.asgi_app / mount_asgi_app. Wrap each mount_app with TimeoutMiddleware when timeout is set. --- src/_bentoml_impl/server/app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/_bentoml_impl/server/app.py b/src/_bentoml_impl/server/app.py index e3ad2c00135..3d887da0d26 100644 --- a/src/_bentoml_impl/server/app.py +++ b/src/_bentoml_impl/server/app.py @@ -25,6 +25,7 @@ from bentoml._internal.container import BentoMLContainer from bentoml._internal.marshal.dispatcher import CorkDispatcher from bentoml._internal.resource import system_resources +from bentoml._internal.server.http.traffic import TimeoutMiddleware from bentoml._internal.server.base_app import BaseAppFactory from bentoml._internal.server.http_app import log_exception from bentoml._internal.types import LazyType @@ -190,6 +191,8 @@ def build_path(*path_segments: str) -> str: self.service.mount_asgi_app(create_proxy_app(self.service), name="proxy") for mount_app, path, name in self.service.mount_apps: + if self.timeout is not None: + mount_app = TimeoutMiddleware(mount_app, timeout=self.timeout) app.router.routes.append(PassiveMount(path, mount_app, name=name)) if self.is_main: From 3000e90c01057044ce88c130fac5f509478a0f49 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 May 2026 06:29:19 +0000 Subject: [PATCH 2/2] ci: auto fixes from pre-commit.ci For more information, see https://pre-commit.ci --- src/_bentoml_impl/server/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_bentoml_impl/server/app.py b/src/_bentoml_impl/server/app.py index 3d887da0d26..07c28190ba6 100644 --- a/src/_bentoml_impl/server/app.py +++ b/src/_bentoml_impl/server/app.py @@ -25,8 +25,8 @@ from bentoml._internal.container import BentoMLContainer from bentoml._internal.marshal.dispatcher import CorkDispatcher from bentoml._internal.resource import system_resources -from bentoml._internal.server.http.traffic import TimeoutMiddleware from bentoml._internal.server.base_app import BaseAppFactory +from bentoml._internal.server.http.traffic import TimeoutMiddleware from bentoml._internal.server.http_app import log_exception from bentoml._internal.types import LazyType from bentoml._internal.utils import is_async_callable