Error in app startup event is not logged and does not prevent startup
See original GitHub issueRelated #431 #177 and mentioned here https://github.com/encode/uvicorn/issues/333#issuecomment-484885300
Scenario: I have a ‘startup’ event handler:
@app.on_event('startup')
async def startup():
initialise()
and I am running under uvicorn for local dev just via the:
if __name__ == '__main__':
uvicorn.run(app, host='0.0.0.0', port=8000)
If there is an uncaught exception in the startup event handler, the exception will be swallowed (not logged) and uvicorn will continue to startup.
The only anomaly seen in the logs is that uvicorn will report:
ASGI 'lifespan' protocol appears unsupported
I would like to see:
- the exception and traceback logged
- process aborted, since we haven’t fully started up yet
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Application.Startup event limitations (bug?) - Stack Overflow
By doing this, the window you just created has become the main window: the one specified in StartupUri will only be created right...
Read more >Troubleshooting startup errors (Windows Server) | Lacuna Docs
1. Application Event Log · Open the Start menu, search for Event Viewer, and then select the Event Viewer app. · In Event...
Read more >Events: startup - shutdown - FastAPI
In this case, the startup event handler function will initialize the items "database" (just a dict ) with some values. You can add...
Read more >Where can we check azure function startup logs in case of ...
Sometimes we are not able to start function application and we would to check logs to understand where was function app stuck.
Read more >“An error occurred while starting the application” in ASP.NET ...
It basically means something really bad happened with your app. Some things that might have gone wrong: You might not have the correct...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@madkote A fix is waiting for review in #488. Feel free to take a look!
Also, keep in mind that maintainers/contributors work on open source projects in their free time (for the large majority). A more gentle « Is there a fix for this yet? » would have been more appropriate. 😃
Since I’m using unicorn via cli option
--lifespan on
helped me