Closed Kikobeats closed 2 months ago
@carpasse can you have a look?
I think what @Kikobeats needs can probably be achieved by creating a wrapper around the responseTime middleware:
function responseTimeWrap(opts) {
var _responseTime = responseTime(opts);
return function (req, res, next) {
return new Promise((resolve, reject) => {
try {
_responseTime(req, res, resolve);
} catch (err) {
reject(err)
}
})
.catch(next)
.then(next);
};
}
We should probably wait until Express next Major v5 supports promises natively before implementing such a change.
Since the codebase is not returning the
next
explicitly, when you have an async interface involving this library, the Promise exit early getting the implicitundefined
until now returned.