-
Notifications
You must be signed in to change notification settings - Fork 56
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
chrome.scripting.executeScript doesn't resolve/reject for frozen
state tabs
#527
Comments
I like the idea to be able to determine if a script can be executed in the particular tab. Besides I am unsure however that it is always possible. A tab may be busy in a tight loop executing some page script function. In general it is susceptible to race conditions since tab state may change between To handle It seems there are 2 different use cases for
To make second use case an atomic operation, it is necessary to add a |
I'd be willing to specify this behavior more clearly, and/or change the default behavior based on options.
Depending on what "frozen" means, this is prone to race conditions and would also require potentially expensive bookkeeping on the browser's end. |
Frozen just means that JavaScript thread is busy. It "freezes" by definition of being single-threaded, so what you're asking is essentially to have a timeout:
When adding code to execute to the event loop, via DOM events or via setTimeout, you basically expect the code to "run eventually". I'm not sure that this situation is substantially different. You can implement your own timeout or perhaps add support for |
In this case it's a discrete state the browser can use: https://developer.chrome.com/docs/web-platform/page-lifecycle-api#states. I don't know if there are internal timeouts but theoretically, it would be possible for it to remain in this state for a long time and then for the script to execute when it is eventually restored.
Agreed on the race condition concern, and a new property on APIs like Also I just wanted to clarify - I'm not a huge fan of the behaviour today. I mentioned in the mailing list that the current behaviour might be ok, but I think that was bad phrasing on my part. What I wanted to call out was that this isn't necessarily a bug, since the request wasn't being lost and did have a chance of eventually being handled. I agree it isn't particularly useful behaviour though (at least, I don't think so). |
Oh, I didn't realize this. Since this is intentional, the browser should really just thaw the tab. The same thing happens when you message the worker: it wakes up after the browser deactivates it. Also yes, since this is an official "state" of the tab, then probably it should be exposed the same way "discarded" is |
Hmm, agreed on the race condition part, but can this race condition not happen currently for discarded tabs as well, then why allow it for a certain state and not for other?
Would adding a flag like |
Prior context:
I originally raised an issue here https://bugs.chromium.org/p/chromium/issues/detail?id=1429905
then started a thread on google groups where @oliverdunk suggested to open an issue here
Problem:
When trying to run chrome.scripting.executeScript over tabs that are in frozen state, the promise doesn't return, neither it resolves nor rejects.
The operation is queued, and when the tab is unfrozen, then the operation runs.
This is problematic, because a developer has no way of knowing that a tab is frozen, so they might try running an operation on such a tab but will get stuck because executeScript will just get stuck.
Suggestions on handling this:
isFrozen
in Tab Object which is returned from chrome.tabs.query() so that user can decide what to do with such tabsThe text was updated successfully, but these errors were encountered: