senchalabs/connect — Issue #485: Error handlers get called in a false way
Author: goloroden
Created: 2012-02-26 18:43:25+00:00
State: open

Prerequisites
- Create a middleware m1 that creates an error and calls next(err)
- Create a middleware m2 that takes (err, req, res, next) as parameters
- Register m1 and m2 using use()

Steps to reproduce:
- Run it

Expected result:
- Error handler is called

Actual result:
- Error handler is called

Now change:
- m1 does not call next(err), but only next()
- Run it

Expected result:
- Error handles is not called

Actual result:
- Error handler is not called

Now change:
- m1 now calls next(err) again
- Change m2 from a function that returns a function to an object with a handle function
- Run it

Expected result:
- Error handler is called

Actual result:
- Error handler is called

Now change:
- m1 does call next() instead of next(err)
- Run it

Expected result:
- Error handler is not called

Actual result:
- Error handler is called with argument.length === 3
- Hence, checking for if(err) does not work :-(