bugtracker
bugtracker copied to clipboard
Remove improper use of promises in Kurento Javascript client implementation.
Client libraries
- Language: JavaScript
- Version: 6.6.0
Browsers tested
- Chrome: FAIL
- Firefox: FAIL
- Native: FAIL
System description: KMS in a Docker container and signal server running on the local machine.
What steps will reproduce the problem?
- Import
kurento-client
package into a browser context. - Create a new, standard
Promise
and within this context... - Call `kurento(URI, (err, client) => {}) to create a client. Resolve the current promise with the client returned by this method.
- Attempt to
await
thePromise
created in step 2.
What is the expected result?
The promise resolves, yielding the client object at the await
call site.
What happens instead?
The promise never resolves because the client
object itself is extended from a Promise
and so the native Promise
implementation assumes it is still waiting on the chain, calls client.then()
which just seems to yield client
and so we are caught in an endless loop where the promise never resolves.
Does it happen with one of the tutorials? No, the tutorials use incredibly verbose and unnecessary nested callbacks rather than any standard Promise implementations.
Please provide any additional information below. Promises should almost never be extended by shared objects. I've looked through the client code and I still can't make heads or tails of why this was actually done in the first place. Seems to be some attempt to ensure connectedness during construction?
Wasted A LOT of time figuring out what was happening. This thing is like #define true false.
Is there any intermediate workaround for this?