balderdashy/sails

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

Aperta

#6988 aperta il 9 mag 2020

 (3 commenti) (0 reazioni) (0 assegnatari)JavaScript (1953 fork)batch import
help wantedmore info please

Metriche repository

Star
 (22.778 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor