balderdashy/sails
在 GitHub 查看sails cannot deal the error "UnhandledPromiseRejectionWarning",but I find express done
Open
#6,988 建立於 2020年5月9日
help wantedmore info please
描述
Node version: v10.15.0 Sails version (sails): v0.12.14
I find express can deal the error "UnhandledPromiseRejectionWarning" by change layer
The code like this: const Layer = require('express/lib/router/layer'); Object.defineProperty(Layer.prototype, 'handle', { enumerable: true, get() { return this.__handle; }, set(fn) { if (fn.length === 4) { this.__handle = fn; } else { this.__handle = (req, res, next) => Promise.resolve() .then(() => fn(req, res, next)) .catch(next); } }, });