Promises sometimes don't get called
See original GitHub issueSpecification
- 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:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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 theassert_js
and not the underlying code.