J
J
jenya77712018-02-16 12:37:46
Node.js
jenya7771, 2018-02-16 12:37:46

What's wrong with node?

What a mistake

(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)

My file which is mentioned in the error is
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 строка
  })

And sometimes, with such an error, more than 10 records are created in the database, in one place, and a bunch of these errors climb, for example, with one request, 5 such errors from one place.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question