question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in app startup event is not logged and does not prevent startup

See original GitHub issue

Related #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:closed
  • Created 4 years ago
  • Reactions:14
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

21reactions
florimondmancacommented, May 31, 2019

@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. 😃

6reactions
kiddtencommented, Apr 24, 2019

Since I’m using unicorn via cli option --lifespan on helped me

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found