express-oauth-server icon indicating copy to clipboard operation
express-oauth-server copied to clipboard

Headers send twice in some cases

Open bzuillsmith opened this issue 9 years ago • 1 comments

When my model returns nothing for model.getAccessToken because the token doesn't exist in the db, I get two responses. The offending lines are here: https://github.com/oauthjs/express-oauth-server/blob/master/index.js#L49-L52

    .catch(function(e) {
        return handleError(e, req, res); // sends an error response
    })
    .finally(next); // executes after .catch and sends another response

I believe it should be the following, but I am not 100% certain since I'm not very experienced with the flow of promises.

    .tap(next)
    .catch(function(e) {
        return handleError(e, req, res);
    });

bzuillsmith avatar Jun 07 '16 00:06 bzuillsmith

Pretty sure this is fixed by getting rid of the .finally(next) statements

chainlink avatar Nov 11 '16 17:11 chainlink