This is a HUGE stress, and also puts you at a disadvantage against your prospect employers.
IMHO, there should be legislation for covering these cases. I.e. when you sponsor a Visa as an employer, it should be mandatory to pay the employee for a minimum of 12-24 months. If you want to lay them off, that's fine, but legally they would still be considered employed and paid in full until that grace period expires.
edit: To be very fair, though, there is an implicit warning in the paperwork and interview for every US work visa for exactly this kind of situation. It's not like they're playing some gotcha game. They don't come right out and say it, but, it's also not exactly hidden between the lines or in small print.
I am NOT 100% sure about this, but to the best of my knowledge, this is not the case in Canada. Work Permits are issues for the duration of the expected work and are usually at least one year long. If you lose your job, you can still remain in Canada until the expiry date of your work permit. You cannot simply start working elsewhere, but if you find a new job, your new employer can start the process of applying for a work permit for you while you are waiting in Canada. So this developer should be good to stay for another 11 to 12 months, if not even longer, while searching for a new job.