Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

improvement: configurable skew protection in create_asgi_app, default False (#5585)

Myles Scolnickcbb7dbf08e48
diff --git a/marimo/_server/asgi.py b/marimo/_server/asgi.py
index b58b2cb7ec..0a541b8eed 100644
--- a/marimo/_server/asgi.py
+++ b/marimo/_server/asgi.py
@@ -296,6 +296,7 @@ def create_asgi_app(
quiet: bool = False,
include_code: bool = False,
token: Optional[str] = None,
+ skew_protection: bool = False,
) -> ASGIAppBuilder:
"""Public API to create an ASGI app that can serve multiple notebooks.
This only works for application that are in Run mode.
@@ -305,6 +306,8 @@ def create_asgi_app(
include_code (bool, optional): Include notebook code in the app
token (str, optional): Auth token to use for the app.
If not provided, an empty token is used.
+ skew_protection (bool, optional): Enable skew protection middleware to prevent version mismatch issues.
+ e.g. if the server is updated, the client will be prompted to reload.
Returns:
ASGIAppBuilder: A builder object to create multiple ASGI apps
@@ -477,6 +480,7 @@ def create_asgi_app(
),
enable_auth=not AuthToken.is_empty(auth_token),
allow_origins=("*",),
+ skew_protection=skew_protection,
)
app.state.session_manager = session_manager
app.state.base_url = base_url