Skip to content
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

Specify behavior when document is not fully active #412

Open
inexorabletash opened this issue Aug 16, 2023 · 5 comments
Open

Specify behavior when document is not fully active #412

inexorabletash opened this issue Aug 16, 2023 · 5 comments
Labels
interop Behavior difference between engines needs-pr needs-tests

Comments

@inexorabletash
Copy link
Member

Related to #381

  1. navigate to https://example.com/ (or anything really)
  2. open devtools/inspector/console/etc
  3. i = document.createElement('iframe');
  4. i.src = location;
  5. document.body.append(i);
  6. ii = i.contentWindow.indexedDB;
  7. ii.open('db'); - returns IDBOpenDBRequest
  8. i.remove();
  9. ii.open('db'); - returns ???

In Chrome this returns null. Throwing is probably more correct behavior. I haven't tested in other browsers.

@asutherland
Copy link
Collaborator

asutherland commented Aug 17, 2023

In Firefox we return our unknown error because we cleared the global from the factory when the iframe's window was cleaned up. In Firefox devtools this looks like:

DOMException: The operation failed for reasons unrelated to the database itself and not covered by any other error code.

We can probably improve the exception message we throw in Firefox at least.

Throwing seems appropriate for a case like this where the API does not return a Promise.

@inexorabletash
Copy link
Member Author

Agreed re: throwing.

For web locks it's spec'd to reject with an "InvalidStateError" DOMException, which seems reasonable to me. I'd prefer to reserve UnknownError for cases when we're in unspecable/untestable territory, whereas this is just an edge case but totally specable/testable. I don't feel strongly about it though.

FWIW, in Chrome localStorage.getItem() throws a "SecurityError" DOMException and caches.open() returns undefined (not a Promise!). Wheee.

@asutherland
Copy link
Collaborator

Yes, InvalidStateError seems better and we're fine to change Firefox's behavior here (and have tests that enforce that as the right exception). Thanks!

@attila-lendvai
Copy link

FWIW, i'm also getting this error with the MetaMask extension, and it completely fails to start now.

UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code.

i have zero clue what goes wrong, where, and how to fix it. deleting the storage would mean hours of work lost.

@asutherland
Copy link
Collaborator

FWIW, i'm also getting this error with the MetaMask extension, and it completely fails to start now.

UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code.

This sounds browser specific. If this is on Firefox, please file a bug against our IndexedDB component and I can respond there. If this is on another browser, please file against that browser (or the MetaMask extension).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Behavior difference between engines needs-pr needs-tests
Projects
None yet
Development

No branches or pull requests

3 participants