Slightly annoyingly spending 10min drafting a comment seems to cause the same on occasion. (I guess there is no activity outside the edit box).
Fortunately if I get an error after posting, usually going back means the text is still there, then it's usually copy the text, click through to the profile of the person I was replying to and post the comment from that page. So far that almost always works.
Weirdly I don't seem to get logged out, just randomly directed to a error page when interacting (e.g. upvoting or trying to comment).
Edit: I don't think I can reliably recreate this issue...