Upvote:3
There is no legal requirements, just the the practical ones dealing with a flight change and immigration and customs. Depending on the airport, you have clear US customs in Canada. In most airports, you have to fully immigrate into Canada first.
This is most likely an Air Canada flight. The list the minimum connection time for each type of connection and each Canadian airport here https://www.aircanada.com/us/en/aco/home/plan/check-in-information/minimum-connection-times.html Scroll down to the section "international to US".
Upvote:6
If you mean "are you legally required to stay at least 4 hours when transitting through Canada" then no, there is no such rule.
Depending on your citizenship and whether you have a visa for the US (rather than Visa Waiver) you will probably need an eTA (Electronic Travel Authorization) to transit through Canada.
Your friend's experience was probably related to a requirement to remain outside the US for a certain time rather than to remain in Canada.