question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

It may be a naive question, but I'm confused with the promise behavior

See original GitHub issue

So I have a middleware doing something like this:

module.exports = async(ctx, next) => {
   dbOperation();
   dbOperation();
   dbOperation();
   dbOperation();
   dbOperation();
   await next();
}

And I see that not all dbOperations are being executed, but if I change to this:

module.exports = async(ctx, next) => {
   await dbOperation();
   await dbOperation();
   await dbOperation();
   await dbOperation();
   await dbOperation();
   await next();
}

Then it works, so is the request finishing before all Promises are correctly dispatched?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
tjcommented, Jul 25, 2016

Yea if you don’t need to wait, then just doing doOperation() is fine, but you’ll want to doOperation().catch(fn) to have some sort of error logging

0reactions
thelinuxlichcommented, Jul 25, 2016

Thanks for all the great tips, guys!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TIP 61 Behavioral Health Services for American Indians and ...
This Treatment Improvement Protocol (TIP) serves as a primer for working with individuals who identify with American Indian and Alaska Native cultures. It...
Read more >
5 Sneaky Behaviors That Are Actually Unhealthy
The following are five common cloaks that could be concealing your partner's covert abuse. 1. Obliviousness. Some people are undeniably spacey, but when...
Read more >
Toxic People: 12 Things They Do and How to Deal with Them ...
We've all had toxic people dust us with their poison. Sometimes it's more like a drenching. Know these 12 signs to avoid falling...
Read more >
Master List of Logical Fallacies
Fallacies are fake or deceptive arguments, "junk cognition," that is, arguments that seem irrefutable but prove nothing. Fallacies often seem superficially ...
Read more >
The Four Horsemen: Defensiveness - The Gottman Institute
One of the Four Horsemen, Defensiveness, is righteous indignation or innocent victimhood in an attempt to ward off a perceived attack.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found