-
Notifications
You must be signed in to change notification settings - Fork 32
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) TypeError: Illegal invocation: Function must be called on an object of type StorageArea #10
Comments
I've currently only tested this up to 68.0.3440.106, which is the current release. |
@KyzaGitHub I think the problem might be when you load in the script - I recommend putting your project into GitHub (rather than a ZIP) as we could then work on a PR to fix. Basically, it looks like you run this script in I think the issue might be timing related because you're still using microtasks for callbacks from
In this context the callback function itself returns a promise, which in turn means anthing after the I think this may be fixed by changing this to:
|
@KeithHenry In order to load the extension faster, I do want some things to run synchronously. I only needed chrome-extension-async.js in order to make sure that some things load in the proper order so the extension does not break, but anything that is not order specific I run synchronously to speed up the loading time. If I understand what you are saying, you mean that by using chrome-extension-async.js I can no longer use callbacks from Chrome APIs like chrome.storage.local? |
Or did you mean that I cannot make a callback asynchronous? |
@KyzaGitHub You can make a callback asynchronous, but it makes it a little hard to predict when the script after any I'm not sure what you mean here:
JS cannot go from asynchronous back to synchronous execution - when you call those without an If you want to do that there are two ways to better catch the result, both using Promise: // Use promise syntax to chain synchronous callbacks
chrome.storage.local.get('key').
then(item => { ... }).
then(followUp => { ... }).
catch(x => console.error(x)); Or: // Get the promise, but don't await for it
const dontBlock = chrome.storage.local.get('key');
// Do other urgent stuff
...
// Now urgent stuff is done, await the result
const item = await dontBlock;
const followUp = await someOtherAsyncCall(item);
... I'd also add that if you're getting performance issues from lots of |
The same here: xcv58/Tab-Manager-v2#235 It only happens on Windows machine. |
Some updates: The functionality works on below versions with Windows 10 OS: does NOT work on the beta and dev versions: |
@xcv58 I don't think think the cause is this, as it's used in other extensions in the same way without error, and I'be been unable to reproduce either your or @KyzaGitHub's issues. All this library does is wrap In both cases this now appears to be resolved, but if it reoccurs could you do me a favour? Try the problem code with the Chrome API without this library, and see if that has the same problem occurs. Either way please let me know, but if it works with the API but doesn't with this wrapper please reopen this issue (or open a new one) with the reproducible details. Thanks. |
@KeithHenry, I just hit this issue too. I have been playing with anyways, I was able to track it down to (step-by-step): basically using the |
It looks like |
@amfr Thanks, will get a new release out with this applied soon. |
@KeithHenry can you please release a bumped version? I'm running into this on MacOS 10.14.2 Chrome Version 71.0.3578.98 |
At least on Chromium 73 when opening the extension options window an exception "TypeError: Illegal invocation: Function must be called on an object of type StorageArea" is thrown, which results in empty update channels page. It looks like chrome.storage.local methods need to be called while bound to the chrome.storage.local object. According to KeithHenry/chromeExtensionAsync#10 wtetsu/mouse-dictionary#16 this Chromium change has been introduced probably around version 70 or 72. Automatic ruleset updates might have been affected by this, too.
I made an extension which works fine, but not on my friend's computer. It throws 3 errors.
I have no idea why it is doing this, it works perfectly fine for me. We are both using the same version of Chrome, Chrome 70.
I attached the extension.
Hypt.zip
The text was updated successfully, but these errors were encountered: