I just had an interesting experience. I was editing a page (with the visual editor, but this isn't strictly a VE issue) and when I went to save the page, got a prompt that my login session had expired and I would not be able to save the page. I was offered the option to discard my changes or save them anonymously (as an IP). If I was in source editing mode, I would have just copy-pasted the source to some temp file on my desktop and not lose any work that way. I briefly thought of switching to source mode, but wasn't sure if my changes would survive the mode switch if I was no longer logged in.
I opted to just save my changes anonymously. For me, leaking my IP was not a big deal, but it might be for other users.
It would be better if the user could be given some advance warning that their session was about to expire. Perhaps if you edit a page and you have less than 30 minutes left, be given a warning that you will need to re-authenticate soon. That way, you can get that taken care of before you begin to make any changes. Another possibility would be to offer to download the source text; in my case, that would have been the ideal thing, but might not be for some platforms (mobile) or situations (working on a public terminal).