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

indexedDB is null in Firefox #40

Open
JamesLMilner opened this issue Apr 21, 2019 · 1 comment
Open

indexedDB is null in Firefox #40

JamesLMilner opened this issue Apr 21, 2019 · 1 comment
Labels
discussion question Further information is requested

Comments

@JamesLMilner
Copy link

Hello! Just noticed this problem with greenlet on Firefox (66.0.3); indexedDB is null in the greenlet execution context.

Reproduction case:

const callIndexedDB = greenlet(async (limit) => {
    console.log(indexedDB);
    // null
});

Also on Chrome (73.0.3683.103) it appears the success callback is never called:

const callIndexedDB = greenlet(async (limit) => {
   var db;
   var request = indexedDB.open("MyTestDatabase");
   request.onerror = function(event) {
     alert("Why didn't you allow my web app to use IndexedDB?!");
   };
   request.onsuccess = function(event) {
     console.log("Success!");
     // Never called
   };
});

Let me know if there's any other information I can provide that might be useful here.

@developit
Copy link
Owner

developit commented Oct 1, 2019

Hiya - this is correct, since Greenlet workers do not have an origin. Even if IndexedDB was accessible from the greenlet function context, it would be a different database than would be accessible in the parent document. This is true for the current Data URL -based implementation, but also for the upcoming switch (back) to Blob URLs.

Unfortunately, the only way to correct this behaviour is to produce an actual file/URL that contains the worker code, which means getting into build process stuff and that's not library territory. For that the only solution I have is workerize-loader which is Webpack-specific.

@developit developit added discussion question Further information is requested labels Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants