Closed ralphch0 closed 6 years ago
Already handled - this is the "abrupt completion" of the callback, which turns into a rejected promise in the steps:
- Let r be the result of invoking callback with a new Lock object associated with lock as the only argument. (Note that r may be a regular completion, an abrupt completion, or an unresolved Promise.)
- Resolve waiting with r.
The spec mentions that if the promise from the callback rejects, the lock is released. I don't think it mentions what happens if there is a synchronous error thrown. eg:
var myvar = null; [...] navigator.locks.acquire('mylock', (lock) => { myvar.mymethod(); // Null pointer!! });
The example above should also release the lock. The risk is that a bug could cause the lock to be held for the lifetime of the tab, when it's not intended.