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.

Nested promises do not seem to fire

See original GitHub issue

Steps to Reproduce

The code below is called via an event handler on the player, then tries to do something, perhaps simply writing to the console, once it is sure that the player has been paused. However, in the case where it is trying to pause the player and then run a callback, the code in the nested promise is never run.

player
    .getPaused()
    .then(function (paused) {
        console.info("Was player paused?: " + paused);
        if (paused) {
            // Do something...
            console.info("Doing something interesting.");
        } else {
            // If the player is not paused, pause it first, then do something...
            console.info("Pausing player");
            player
                .pause()
                .then(function () {
                    console.info("Doing something interesting post-pause - this never runs");
                });
        }
    });

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
bdoughertycommented, Nov 14, 2016

@paulmolluzzo does the element you’re passing in have a data-vimeo-id attribute? If not, that’s the reason (the null load is definitely something that should be fixed in the library though).

When you first create the player object, either add the data-vimeo-id attribute to the element first or pass the id in as the second param:

player = new Vimeo.Player(some_element, {
    id: 152464736
});
1reaction
nicotroiacommented, Oct 19, 2016

Follow up: (please let me know if this is off-topic and I can start a new thread)

I hadn’t noticed this before, but on the videos that don’t load/autoplay, will flash an error briefly in the player. “Unhandled video privacy”.

And in the console it says: player.js:7 Refused to load the image 'https://player.vimeo.com/video/152464736' because it violates the following Content Security Policy directive: "img-src https://i.vimeocdn.com https://secure-b.vimeocdn.com https://f.vimeocdn.com https://vimeo.com https://sb.scorecardresearch.com https://ssl.google-analytics.com https://secure.gravatar.com https://i0.wp.com https://i1.wp.com https://i2.wp.com https://f.vimeocdn.com".

If the error handler fired, I could at least skip this particular video, but it seems to not notify me. Any idea why this would be happening? Thanks for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Please don't nest promises - DEV Community ‍ ‍
The issues with promises only begin to appear when multiple asynchronous operations need to be executed one after the other in a specific...
Read more >
Nested promises with for loop doesn't work - Stack Overflow
The calls are made correctly, because if I use Promise.all([promises here]) , then it works. But I'm trying to learn to chain promises...
Read more >
Using promises - JavaScript - MDN Web Docs
A Promise is an object representing the eventual completion or failure of an ... The first mistake is to not chain things together...
Read more >
A Guide to Nested Promises, Anti-Pattern, and Alternatives
Promise in JavaScript is a popular design pattern used to handle asynchronous tasks in Node.js. It can take care of parallel/serial ...
Read more >
Error handling with promises - The Modern JavaScript Tutorial
Normally, such .catch doesn't trigger at all. But if any of the promises above rejects (a network problem or invalid json or whatever),...
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