As a software developer, more frequently than I'd like. Pouring a couple weeks into an epic only to see the entire thing scrapped... At least I got paid.
Happens with personal projects too sometimes, I'll start refactoring and decide at the end of the weekend I really don't want to waste me next weekend on it and it'll go to the archives lol.
But even in those cases, not entirely worthless. I still learned and grew my knowledge. Same applies to similar scenarios not related to writing code.
Had a thing about this at work this week. Got a small project in that is loaded up with garbage requirements, client is never coming back to us after this, and the budget is marginal.
What's the point? We aren't getting new knowledge, we aren't establishing a relationship with a new client, we aren't even making money. Sales fucked up, these things happen, move on. It isn't even a challenging assignment so the entire victory is hollow. Boss-man didn't like my brilliant idea to just ghost the client.