Skip to content

Conversation

@danxuliu
Copy link
Member

Follow up to #3913

Promise.finally is available in older browsers for "hand-made" promises, probably due to a shim or to the code being transpiled (I have not checked). However, it is not available for internal promises returned by navigator.mediaDevices.getUserMedia().

Moreover, in some browser versions (Firefox >= 58 && <= 68) there seems to be a clash between the internal promise and the shimed/transpiled one, as Promise.finally is available for getUserMedia promises, but not when used in Nextcloud.

Due to all that finally uses were replaced by a function called at the end of then and catch.

  • Firefox < 58:
    • Empty browser page:
      • new Promise((resolve, reject) => { setTimeout(() => { resolve() }, 1000) }).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> finally is not a function
      • navigator.mediaDevices.getUserMedia({audio: true}).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> finally is not a function
    • Talk:
      • new Promise((resolve, reject) => { setTimeout(() => { resolve() }, 1000) }).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> Works 👍
      • navigator.mediaDevices.getUserMedia({audio: true}).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> finally is not a function
  • Firefox 58-68:
    • Empty browser page:
      • new Promise((resolve, reject) => { setTimeout(() => { resolve() }, 1000) }).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> Works 👍
      • navigator.mediaDevices.getUserMedia({audio: true}).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> Works 👍
    • Talk:
      • new Promise((resolve, reject) => { setTimeout(() => { resolve() }, 1000) }).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> Works 👍
      • navigator.mediaDevices.getUserMedia({audio: true}).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> finally is not a function
  • Firefox > 68:
    • Empty browser page:
      • new Promise((resolve, reject) => { setTimeout(() => { resolve() }, 1000) }).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> Works 👍
      • navigator.mediaDevices.getUserMedia({audio: true}).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> Works 👍
    • Talk:
      • new Promise((resolve, reject) => { setTimeout(() => { resolve() }, 1000) }).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> Works 👍
      • navigator.mediaDevices.getUserMedia({audio: true}).then(() => { console.log('Done') }).finally(() => { console.log('Finally') }) -> Works 👍

"Promise.finally" is available in older browsers for "hand-made"
promises, probably due to a shim or to the code being transpiled (I have
not checked). However, it is not available for internal promises
returned by "navigator.mediaDevices.getUserMedia()".

Moreover, in some browser versions (Firefox >= 58 && <= 68) there seems
to be a clash between the internal promise and the shimed/transpiled
one, as "Promise.finally" is available for "getUserMedia" promises, but
not when used in Nextcloud.

Due to all that "finally" uses were replaced by a function called at the
end of "then" and "catch".

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@nickvergessen nickvergessen merged commit 87f998e into master Aug 25, 2020
@nickvergessen nickvergessen deleted the do-not-use-finally-on-promises-returned-by-getusermedia branch August 25, 2020 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants