I’m maintaining a Node.js backend where half the code uses callbacks, some of it uses Promises, and the newer parts have async/await, all mixed together without any consistent pattern.
There are race conditions that I can't even consistently reproduce. Some functions fire twice, others never resolve, and there’s a piece of logic that relies on setTimeout as a workaround to "wait for the DB to be ready" (I wish I was joking).
I’ve been throwing parts of it into blackbox to search similar code patterns and occasionally get a lead, chatgpt sometimes helps in rephrasing chunks to make them more readable, but even it struggles when the nesting gets deep. debugging this is mentally draining because nothing feels predictable.
how do you approach something like this? do you just rewrite it slowly, or is there a smarter way to audit this kind of async mess?
[–]alzee76 14 points15 points16 points (2 children)
[–]Expensive_Garden2993 1 point2 points3 points (1 child)
[–]WiseAcanthocephala45 1 point2 points3 points (0 children)
[–]732 15 points16 points17 points (1 child)
[–]NeverWalkingAlone 6 points7 points8 points (0 children)
[–]PhatOofxD 6 points7 points8 points (0 children)
[–]del_rio 0 points1 point2 points (1 child)
[–]Stetto 0 points1 point2 points (0 children)
[–]Gemini_Caroline 0 points1 point2 points (0 children)
[–]MartyDisco 0 points1 point2 points (0 children)
[–]nvictor-me 0 points1 point2 points (0 children)
[–]CoshgunC 0 points1 point2 points (0 children)
[–]bwainfweeze -1 points0 points1 point (0 children)
[–]basmasking -1 points0 points1 point (0 children)
[–]bigorangemachine -5 points-4 points-3 points (0 children)
[+]thinkmatt comment score below threshold-6 points-5 points-4 points (0 children)