balderdashy/sails

sails cannot deal the error "UnhandledPromiseRejectionWarning",but I find express done

Open

#6,988 opened on May 9, 2020

View on GitHub
 (3 comments) (0 reactions) (0 assignees)JavaScript (22,778 stars) (1,953 forks)batch import
help wantedmore info please

Description

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); } }, });

Contributor guide