Had something like this happen years ago when my YYZ-LAX flight was cancelled due to weather shortly before boarding. Since everyone had "entered" the US, we had to go through Canadian customs and pick up our bags from the transborder arrivals area. In this case, AC reps accompanied our group through customs and no forms or anything else had to be dealt with. Customs hall was empty at the time so I guess there was no concern about us intermingling with legit US arrivals.
Also had a similar event occur at PVG when our flight had to turn back from taxiing out due to thick fog. The flight was cancelled and we were all off-loaded and led through Chinese immigration/customs. Now in China you'd expect all sorts of bureaucratic hassles and the like due to expired visas, multi-entry on single entry visas, etc. However, the Chinese agents were very blasé about the whole thing and just waved us through. We didn't have to fill anything out or get new visa stamps. Next morning also expected some hassles leaving with already stamped exit visas but once more, no problems.
If I was producing the border series, I'd certainly want to include this vignette as a light hearted event.