-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught (in promise) DOMException: LockManager.request: request() is not allowed in this context #114
Comments
promises functions as the name suggest are async, you can't execute a stat on the next line without await in front. |
Check this demo https://codepen.io/jcubic/pen/zYLdPxK?editors=0011 and you should not use |
If you can create a demo that will clean after itself it would be great. |
The error itself looks like a problem with observablehq, if you can please create a self-contained code without any extra middleman. |
Also if error came from lightning-fs when creating FS please try to minimize the usage of libraries and Use only things to make reproducing the error possible. You don't even use isomorphic-git properly because there is no "master" branch in git repo. |
Yeah, didn't give you a minimal example, sorry about that. This however works in chrome/edge. So it can't be a problem with observablehq. |
|
ok, managed to somehow reproduce it. Line 31 in b041900
new Promise((resolve, reject) => {
const controller = new AbortController();
setTimeout(() => {
controller.abort();
reject(new Error("Mutex timeout"));
}, 3);
navigator.locks.request(this._database + "_lock", {signal: controller.signal}, (lock) => {
this._has = !!lock;
resolve(!!lock);
return new Promise((resolve2) => {
console.log('aaa');
window.helpme=resolve2;
});
});
}); |
But it works when I use the same code outside of CodePen. This is my own playground that I work on and it works fine there: https://p5.javascript.org.pl/motionless-age?template=none&base=base.js |
I suspect that this may be something with Sandboxing, I don't use any protection on my playground. Maybe I will add some kind of Sandboxing later in the process. My application is a prototype. Anyway, I contacted CodeSanbox support maybe they will know what is happening. If a lock can't be used in the Sandboxed environment then the library should protect against it, maybe disabling the lock, use something else, throwing a proper error, or maybe showing a warning. |
Another explanation is that this is a bug in Firefox. I don't see any information about Sandbox on MDN. |
I've contacted CodePen support they can reproduce the issue but don't have a solution. I will try to recreate the issue on sandboxed iframe. |
https://bugzilla.mozilla.org/show_bug.cgi?id=1798493 hmm, can we maybe detect this case and downgrade or at least give a meaningful error message |
In Firefox, see https://observablehq.com/@a10k/hello-lightning-fs-isomorphic-git
Works perfectly in chrome but when creating the new filesystem, DOM refuses.
The text was updated successfully, but these errors were encountered: