Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG FIX] Exception handling and enabling graceful shutdown of connection #2130

Closed
wants to merge 13 commits into from

Conversation

IronJam11
Copy link
Contributor

PR Description:

Closes #1350

Deliverables:

  • Adds logging for errors encountered in the handle() function.
  • Ensures graceful shutdown of the connection in the event of an error.

Changes:

  • Error Handling in handle():

    • Added a try-except block to catch exceptions during the handle() function execution.
    • Logs the error with a detailed traceback using logger.error().
    • Sends a 500 Internal Server Error response using self.send_response() when an error occurs.
    except Exception:
        logger.error(f"Error in handle(): {traceback.format_exc()}")
        await self.send_response(500, b"Internal Server Error")
        raise
  • Graceful Shutdown:

    • Ensured that after sending the error response, the connection is gracefully terminated using self.send_response().
  • Improved Error Handling in http_disconnect():

    • Added robust error handling during the disconnect phase to ensure proper cleanup and termination of the connection.

@IronJam11 IronJam11 closed this Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connection won't be closed if raise exception in AsyncHttpConsumer::handle()
1 participant