It obviously varies by individual and by team, but in general the solution is more communication, earlier in the process, and frequently throughout it.
The thing designers often don't understand is how their design needs to work within the larger system, which has many complex interactions, tradeoffs, and constraints. Changing one thing entails changing many other, non-obvious things, and did you think about that when you drew a picture of it working perfectly in Figma? No?
The thing developers often don't understand is that designers work without the benefit of certainty. They may get a set of requirements from a PM, but often they don't, or they don't get a very good one. Do all the user interviews you want, you're still just guessing about a hundred times a day. And there is no automated testing or static analysis. There isn't even syntax highlighting. You just make something you hope is right, then show it to people, and have them point out all your mistakes. Of course they get defensive and protective of their jobs.
So developers and designers need to be in communication with each other frequently, to spot problems early and fix them. And it needs to be so common and lightweight an interaction that it doesn't feel like a committee meeting, but like a collaboration between partners with the same goal.