Gmail – How does Gmail’s Un-send feature work

gmail

Google's Gmail has the feature that allows you to Un-send an email within a few seconds after hitting send. I can of course guess on how this works but I've never been able to find any specific details on how this might be accomplished.

My theory

Basically I imagine the way this works is that Google is able to track the state or status of an email coming into their servers and/or being delivered to the recipient. An email sent through Gmail would initially be in some kind of "uploading" state and the Gmail browser client would continually read the state of the email until it changes to "unretrievable" at which point the message changes to "Sent" and the undo option disappears.

My main question around this is how do they prevent race conditions?

For example what if I click on the Un-send button milliseconds before the status changes to unretrievable and my Un-send packet doesn't reach the server fast enough.

What kind of reversal process would occur?

How does Gmail's Un-send feature work and specifically how do they prevent race conditions?

Best Answer

Quite simple. It quite literally does not send the mail until the time is up. And if you're too slow, too bad, the mail's been sent to the other server.

I don't think they'd bother with absolute last minute regrets, and people dramatically reaching for the undo button at the last moment, while it makes for good excessive drama, isn't really a concern.

There's no 'takie backies' in email.