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.

Promises sometimes don't get called

See original GitHub issue

Specification

  • pywebview version: 3.0.2
  • platform / version: MacOS Catalina

Description

Initiate a function call from python to javascript multiple times. Observe that the function does get called multiple times but only one value is returned to Javascript via promise.

    for (let i = 0; i < 10; i++) {
        console.log('request ' + i);
        api.echo(i).then((j) => {
            console.log('response ' + i)
        })
    }
class JSApi:
    def echo(self, value):
        print(value)
        return value

Javascript output:

[Log] request 0 (main.js, line 39)
[Log] request 1 (main.js, line 39)
[Log] request 2 (main.js, line 39)
[Log] request 3 (main.js, line 39)
[Log] request 4 (main.js, line 39)
[Log] request 5 (main.js, line 39)
[Log] request 6 (main.js, line 39)
[Log] request 7 (main.js, line 39)
[Log] request 8 (main.js, line 39)
[Log] request 9 (main.js, line 39)
[Log] response 0 (main.js, line 41)

Practicalities

  • YES I am willing to work on this issue myself.

  • NO I am not prepared to support this issue financially.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
r0x0rcommented, Oct 15, 2019

I have pushed a tentative fix to the js-api-fix branch. It is mostly untested, tests should be fixed and Windows binaries should be regenerated as well.

0reactions
r0x0rcommented, Oct 23, 2019

test_js_api::test_concurrent randomly fails on Windows. After hours of debugging I could not track the cause of the bug down. I won’t spend any more time trying to fix it and let it be for the time being. Let’s hope it is a bug in the assert_js and not the underlying code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why would JavaScript Promises sometimes neither use .catch ...
The promise constructor is for converting things that are not promise returning into things that are promise returning. If you're using bluebird ...
Read more >
How to Deal With People Who Don't Do What They Say |
Broken promises, even small ones, cause problems. Things don't get done, relationships break down, and trust erodes. And if you're on the receiving...
Read more >
We have a problem with promises - PouchDB
Each function will only be called when the previous promise has resolved, and it'll be called with that promise's output.
Read more >
Tired Of Being Let Down? How To Hold People Accountable
Many people value their promises cheaply or simply manage their commitments poorly. Others have a hard time holding people to account. It's ...
Read more >
Promise - JavaScript - MDN Web Docs
A promise is said to be settled if it is either fulfilled or rejected, but not pending.
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