My advice: Have one or more side projects going all the time. If you get laid off, immediately start doing a startup, open-source project, or volunteering full time. A year of unemployment? Lonely, depressing, and not good on a resume. A year of launching an unsuccessful venture? Running coding classes for the underserved? Focusing full-time on contributing to pytorch? That's a lot better, both at the time and in ret…
This is a live-to-work attitude. Have some other hobbies and goals, and a year of unemployment will be neither lonely nor depressing. Personally I've gone farther in the work-to-live direction, with an easygoing, "boring" (still fulfilling enough to see some javascript doodad come to life, but not world changing) WFH job I perform well in that supports my homesteading and other hobbies.
I have met soo many sysadmins and devs that absolutely hate computers, hate programming, hate everything about IT. They were in some career fair at some point in high school and simply picked that because it had high pay with out the 6 or 8 years being a Doctor or lawyer took, and it seemed easier than Electrical Engineering or something.
Me, I have always loved programming and computers. They are both my work and my hobby