failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · fastapi/fastapi
🐛 Fix `on_startup` and `on_shutdown` parameters of `APIRouter`
This fixes the issue reported in this comment: https://github.com/fastapi/fastapi/pull/14851#issuecomment-3863896385
```py
from fastapi import FastAPI
def s_start():
print("SYNC START", flush=True)
app = FastAPI(on_startup=[s_start])
@app.get("/health")
async def health():
return {"ok": True}
```
Startup event is not called because `APIRouter.on_startup` is set in `APIRouter.__init__` before calling `super().__init__` and is overridden by `router.__init__` (https://github.com/Kludex/starlette/blob/e5b8a5d200504a2608bed11fe6f66b1d20b9ae2c/starlette/routing.py#L597-L598)| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||