Skip to content

Starlette 1.0 breaks Solara import: Starlette.__init__() no longer accepts on_startup / on_shutdown #1143

@EwoutH

Description

@EwoutH

Description

With starlette==1.0.0rc1, importing solara.server.starlette crashes:

TypeError: Starlette.__init__() got an unexpected keyword argument 'on_startup'

Cause: solara/server/starlette.py constructs the app at import time using removed kwargs:

app = Starlette(routes=routes, on_startup=[on_startup], on_shutdown=[on_shutdown], middleware=middleware)

Starlette 1.0 removed on_startup / on_shutdown (replaced by lifespan).

To reproduce

pip install --pre solara starlette
python -c "import solara.server.starlette"
# (also triggers during pytest plugin discovery if solara is installed)

Expected

Solara imports / runs with Starlette 1.0 (or at least doesn’t hard-fail during pytest plugin autoload).

Suggested fix

Use Starlette’s lifespan= instead of on_startup / on_shutdown (or gate by Starlette version).

See Starlette Lifespan docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions