balderdashy/sails

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

Open

#6 988 ouverte le 9 mai 2020

Voir sur GitHub
 (3 commentaires) (0 réactions) (0 assignés)JavaScript (1 953 forks)batch import
help wantedmore info please

Métriques du dépôt

Stars
 (22 778 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

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

Guide contributeur