channels icon indicating copy to clipboard operation
channels copied to clipboard

Add error handling and enable graceful shutdown

Open IronJam11 opened this issue 10 months ago • 4 comments

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 avatar Jan 30 '25 12:01 IronJam11

Made the changes as requested

IronJam11 avatar Jan 30 '25 15:01 IronJam11

I was a bit caught up with a hackathon. apologies for the wait.

IronJam11 avatar Feb 04 '25 05:02 IronJam11

No problem. No rush. I need to find a cycle to sit down with this properly. 👀

carltongibson avatar Feb 04 '25 06:02 carltongibson

Any update on this PR?

cheehong1030 avatar Oct 23 '25 04:10 cheehong1030