Chat allows two minutes for editing a message, and if there are less than 10 seconds left for editing a chat message, the following warning is displayed:
You have less than 10 seconds left for editing.
This value may be less than 10 if the edit was started with less than 10 seconds remaining. Once this time expires, the edit cannot be submitted.
While comments to questions and answers can be edited for five minutes, no warning is displayed if time is about to expire while editing, and a user can attempt to submit an edit to a comment after time expires only to get the "Comments can only be edited for 5 minutes" error.
It would be a good idea to add this warning for editing comments, perhaps starting from 15 seconds, with the submit button disabled once the timer expires. That way, the user doesn't get frustrated if time runs out. In any case, if the user feels the edit is necessary anyway, the Markdown code of the comment can be copied, a new comment can be posted, and the old comment can be deleted.
This would also address the problem described in this question by ensuring that the user knows whether he/she is running out of time to submit the edit.