Что за ошибка
(node:24660) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 11): 1
(node:24660) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 12): 1
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:357:11)
at ServerResponse.header (/Users/jenya/Documents/sockses_pg/node_modules/express/lib/response.js:767:10)
at ServerResponse.location (/Users/jenya/Documents/sockses_pg/node_modules/express/lib/response.js:884:15)
at ServerResponse.redirect (/Users/jenya/Documents/sockses_pg/node_modules/express/lib/response.js:922:18)
at models.sockses.create.then (/Users/jenya/Documents/sockses_pg/controllers/components/sockses.js:416:7)
at tryCatcher (/Users/jenya/Documents/sockses_pg/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/jenya/Documents/sockses_pg/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/jenya/Documents/sockses_pg/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/jenya/Documents/sockses_pg/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/jenya/Documents/sockses_pg/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/Users/jenya/Documents/sockses_pg/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/jenya/Documents/sockses_pg/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/jenya/Documents/sockses_pg/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
Мой файл который упоминается в ошибке
at models.sockses.create.then (/Users/jenya/Documents/sockses_pg/controllers/components/sockses.js:416:7)
.then((data) => {
servises.cash.flowDelete(req.user.id)
req.flash('type', 'warn');
req.flash('message', 'Ошибка');
res.redirect(req.url); //416 строка
})
И иногда при такой ошибке в базе создаётся более 10 записей, в место одно, и эти ошибки лезут куча, например при одном запросе 5 таких ошибок из одного места.