textual icon indicating copy to clipboard operation
textual copied to clipboard

Added waring when message handling take long time

Open Piechutowski opened this issue 1 year ago • 0 comments

This PR resolves #4895

cc @willmcgugan

Implemented Features:

  • Warning for Slow Handlers: Logs a warning if a message handler takes longer than 500ms to process.
  • Debug Mode Only: Warnings are enabled only in debug mode to avoid unnecessary overhead in production.
  • Configurable Threshold: The time threshold before a warning is issued can be set via the TEXTUAL_SLOW_THRESHOLD_MS environment variable.

Known Limitations:

Currently, the warning is logged only after the message handler completes. This means that if a handler takes an extended time (e.g., 30 seconds), the warning won’t appear until it finishes. I have attempted to implement a solution that handles this case in real-time but haven't been able to get it working as intended yet.

Request for Feedback:

If the current implementation is satisfactory, I would appreciate feedback on how to improve the async version for real-time warnings.

Piechutowski avatar Aug 20 '24 13:08 Piechutowski