The most recent hiatus I've taken as a writer was about 3-4 years. I got really busy in those years, getting a new job after graduating from college during the pandemic lockdown, having to adjust to the chaos, trying another job, etc. The jobs really sucked the joy of writing for me too. I've been back for about a year now and writing more seriously than before.
As for writer's block, I'm currently going through it. But usually during a writer's block, I find that listening to music online that resonates with whichever story I'm writing, watch movies, or read others' works to become a better writer--all help me move through the writer's block. What I also find that helps me to exit the writer's block is just write whatever comes to mind that is related to the story, either outlining or start freewriting until something clicks.
For those who are writing, if possible--try to finish the book or story. I'm close to finishing my first series, and I found out that I've learned a lot--more than ever before--about writing because I'm about to complete my story. I've followed web novel authors where their first series/book had an 'okay' ending, but usually in the next series/book, I can see so much improvement; I can tell that they learned a lot from completing that first series/book.