There's a happy medium somewhere between the wasteland of legacy "enterprise" jobs (.NET 2.0 and such) and the nutzo SF/SV orbit.
I live in Southern California (LA/OC). It's not cheap by any measure but it's within the bounds of economic sanity compared to SF/SV. There are tons of very interesting tech jobs in cutting edge areas like computer vision, AI/ML, the latest web and DevOps tech, and a lot of hardware/EE stuff. There are many other places like this. Canada probably has a few too. Even NYC, which is more expensive than LA, is still "sane" compared to SF when you consider what you get. In NYC car ownership is very optional, which mitigates the high rents, while in SF you must own a car if you ever want to leave the peninsula.
I've turned down numerous offers in SF/SV because it just seems economically insane. The housing prices are clearly unsustainable and the OP's comment about it being a "serious life mistake" rings true. The craziness has also priced out much of the interesting culture that made SF compelling in the first place.
Edit: I keep hearing about the relentless ageism in SF/SV tech. I don't see so much of it elsewhere. Is it really that bad? If so it seems like a SF/SV thing and not necessarily true everywhere. In that case it might make some sense for young people to spend some time in SF/SV getting into the latest stuff and learning and then bail before 30.