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.

Promises hang on empty selection result

See original GitHub issue

var promise = $.Velocity.animate($('.something-not-exist'), { duration: 100 });

I’m expecting the returned promise to be completed with either a success or a rejection, but it ends up being pending forever.

Personally, I prefer the promise to be resolved immediately in this case.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

Rycochetcommented, May 5, 2016

Promises should always resolve one way or another - my personal view is that this should succeed as we don’t know if being passed an empty NodeList is deliberate or not - possibly add an option to rejectEmptyPromise or similar though?

lobenichoucommented, Nov 22, 2016

@Rycochet Sure, no problem. I copy-pasted last minute before leaving work. It’s basically the same code you have in your documentation.

var mySequence = [
    { e: $element1, p: { translateX: 100 }, o: { duration: 1000 } },
    { e: $element2, p: { translateX: 200 }, o: { duration: 1000 } },
    { e: $element3, p: { translateX: 300 }, o: { duration: 1000 } }

And I am 100% sure that it stops after $element2 because it return an empty NodeList. When I have more time today, I will put together a JSFiddle together.

Thank you for your quick response.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise.all([]) returns a resolved promise, but Promise.race ...
It's defined in the docs (race): "If the iterable passed is empty, the promise returned will be forever pending." Promise.all docs: "If an...
Read more >
Promise - JavaScript - MDN Web Docs
The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
Read more >
Biden Promise Tracker | PolitiFact
The Biden Promise Tracker monitors the 100 most important campaign promises of President Joseph R. Biden, elected in November 2020. Biden said his...
Read more >
typescript-eslint/ at main - GitHub
Floating Promises can cause several issues, such as improperly sequenced operations, ignored Promise rejections, and more.
Read more >
Use Promise.all to Stop Async/Await from Blocking Execution ...
Let's refactor the code we've written so far in this article using async functions to make it a little easier to read: async...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found