Reputation: 173
Our backend is built with Express (1.4.0) and Typescript. A route has two callbacks:
At one point, the error callback started being ignored. After lots of debugging, we found out that Express uses the callback parameter count to identify and execute an error callback, and if it's not found, then it calls the next callback in the stack.
We realized this bug was introduced when we cleaned up the unused parameters in our code. In this case, it was next
.
We added the fourth parameter and we added a warning comment. But how can we prevent this from happening again? Is there a way to add a lint rule or perhaps something with Typescript?
Upvotes: 5
Views: 183