greenlet
greenlet copied to clipboard
indexedDB is null in Firefox
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.
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.