There's an obvious solution to this: don't treat websites like programs, and never trust sites.
I learned this lesson over a decade ago. After being burned over and over because some shitty browser or site bug ate my post I now use One Weird Trick on every post I write:
1. Write it.
2. Select it and Ctrl+C it.
3. Post it.
If the post gets eaten, the text is safe in the clipboard, waiting for another go. This is for shorter posts. For longer ones, multi-paragraph stuff considered over hours or days, it lives in Notepad until it's ready to post. NEVER compose anything in a webpage form. They just can't be trusted.