bugtracker icon indicating copy to clipboard operation
bugtracker copied to clipboard

Remove improper use of promises in Kurento Javascript client implementation.

Open dkushner opened this issue 7 years ago • 2 comments

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?

  1. Import kurento-client package into a browser context.
  2. Create a new, standard Promise and within this context...
  3. Call `kurento(URI, (err, client) => {}) to create a client. Resolve the current promise with the client returned by this method.
  4. Attempt to await the Promise 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?

dkushner avatar Jul 14 '17 22:07 dkushner

Wasted A LOT of time figuring out what was happening. This thing is like #define true false.

waifutech avatar Aug 21 '17 12:08 waifutech

Is there any intermediate workaround for this?

virtualfunction avatar Sep 17 '17 13:09 virtualfunction