express-oauth-server
express-oauth-server copied to clipboard
Headers send twice in some cases
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);
});
Pretty sure this is fixed by getting rid of the .finally(next) statements