Last time I went to Japan, I connected through Vancouver airport in Canada. I had to go through Canadian customs because they don't segregate all international flights. Bizarrely, the customs guy looked at my ticket, then asked how long I intended to stay in Canada (my connecting flight was in ~2hrs).
For the same reason, on return, I couldn't bring back any Japanese booze from the airport. I had to go through a second liquids and customs check at YVR.
Canada does have transit lounges - but Vancouver is a bit odd. They have pre-cleared US immigration, so you have effectively 3 airside zones domestic/US/International.
So if you are coming off/going to a US flight from an international one you have to go out and back in. There is a US <-> International security gate but it's not normally staffed
And screw ups happen - I lost a Lufthansa bottle of champagne they gave me on board for screwing up my seat. At a change in Frankfurt the we had to be bussed from the plane to the terminal - the bus dropped us outside security and I lost the sealed Lufthansa labeled champagne to the security desk.
For the same reason, on return, I couldn't bring back any Japanese booze from the airport. I had to go through a second liquids and customs check at YVR.