3 ms·
I’ve been debugging a fair amount of service traffic lately, and I think I’ve about hit breakpoints in all of the major http client implementations in Node. ..
by hinkley 7y ago
I’ve been debugging a fair amount of service traffic lately, and I think I’ve about hit breakpoints in all of the major http client implementations in Node.
...
Every single one of them has so much delegation (to achieve some fucked up definition of minimalism) that it’s not even funny. And with async await it’s downright maddening. Even in node 12 with the async stack traces flag.
I’m taking over maintenance of a service and it’s throwing an unhandled promise rejection that’s a 403 error with a one line stack trace (which is in the wrapper we wrote because the library somehow isn’t minimalistic enough for our tastes). Took way too long to catch in papi. The stack trace is huge, none of our code in it at all, and the request is not even in scope for two or three frames away from where the error is thrown. This is, from a user’s standpoint, an awful library.
Anything I struggle to debug, I can guarantee at least a few of my coworkers will bring the same problem to me. Which means I spend three times as much time looking at bad library code as a junior developer would. That fosters a lot of contempt for code that is ugly on the inside.
What I really want as an industry is for us to start judging third party code by how sane the stack traces look. This has been bugging me ever since J2EE traces started going north of three pages (with the same series of four frames appearing three times). And sane stacks are going to require us to stop avoiding having a bunch of methods with a single line of duplicated code in them. Quelle horreur!
The whole point of code reuse is to reduce duplicated effort not lines of code. Arcane call stacks are huge amounts of duplicated effort, by people already having a bad day.
DRY is not worth all the lost hours and energy wasted in debuggers. Do better.