Tampermonkey / tampermonkey

Tampermonkey is the most popular userscript manager, with over 10 million users. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox.
GNU General Public License v3.0
4.19k stars 417 forks source link

[Firefox] Scripts randomly stop working #477

Closed darkred closed 2 years ago

darkred commented 6 years ago

Tried TM 4.5.5633 stable and 4.5.5648beta in FF 57.0.1 x64 in win10.

The issue I have is this:

I haven't managed to recreate this with a fresh FF profile.

Here is a log from Browser Console (TM 4.5.5633 stable) as I disable TM via the toolbar button (having only TM enabled):

Try to load layout default  layout.js:3
No matching message handler for the given recipient. MessageChannel.jsm:703
Storage: use chromeStorage  storage.js:19
Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist. ExtensionCommon.jsm:407
Storage: test -> start  storage.js:11
Storage: test -> set after 502ms  storage.js:11
Storage: test -> get after 504ms  storage.js:11
Storage: test -> remove after 1010ms  storage.js:12
Unchecked lastError value: Error: Promised response from onMessage listener at addListener@moz-extension://eacdd3d4-ef20-4256-ae58-3eb85f85fa83/rea/common.js:3:291 went out of scope ExtensionCommon.jsm:407

and, as I re-enable TM via the toolbar button:

Try to load layout default  layout.js:3
Unchecked lastError value: Error: Promised response from onMessage listener at addListener@moz-extension://eacdd3d4-ef20-4256-ae58-3eb85f85fa83/rea/common.js:3:291 went out of scope  ExtensionCommon.jsm:407
Ignoring response to aborted listener for 575-4
Ignoring response to aborted listener for 576-4
Ignoring response to aborted listener for 577-4
Ignoring response to aborted listener for 578-4
Ignoring response to aborted listener for 579-4
Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist.  ExtensionCommon.jsm:407
Storage: use chromeStorage  storage.js:19
Storage: test -> start  storage.js:11
Storage: test -> set after 502ms  storage.js:11
Storage: test -> get after 503ms  storage.js:11
Storage: test -> remove after 1005ms  storage.js:12

I don't have any special TM settings enabled (especially, in Settings | General, the "Auto reload pages" setting remains disabled, as by default)

If there's anything more I can provide to help, please ask.


I have ~200 userscripts installed. For reference, with the same number of scripts in Greasemonkey 4.0 or 4.1beta6 I didn't have such an issue.


My other addons are uBlock Origin 1.14.20, Reddit Enhancement Suite 5.9.3beta and Stylus, but even if I disable them, the issue still occurs.

derjanb commented 6 years ago

I can not reproduce this issue. For me scripts are working fine after Tampermonkey is enabled again. Can you please create a new Firefox profile and test with only Tampermonkey installed and one script? Does that work? If so does it still work with all scripts installed (you can export and import them at the "Utilities"tab).

darkred commented 6 years ago

Yes. of course. So:


I tried the following test with a fresh FF 57.0.2 x64 profile profile with only either TM 4.5.5633 or TM 4.5.5648beta:


Now, I tried exporting (ZIP) my scripts and importing them to the fresh profile:


But, I tried opening another URL (I'd prefer to send this to you privately) in that fresh profile, and upon e.g. 5 times it will surely occur - it happened to me 2 times in 20 tries or so.


  So, would it be ok if I sent you my ZIP archive and that URL, via pm in the TM forum, to take a look at it?

derjanb commented 6 years ago

Sure. You can also send an email to support<ät>tampermonkey.net (since I'm the only one behind TM it will reach only me :)

darkred commented 6 years ago

I just sent you an email. Thank you.

darkred commented 6 years ago

With the new version 4.5.5660 the issue is fixed! Thanks a lot! (please see below)

darkred commented 6 years ago

Unfortunately, I spoke too soon: although with with the new version I may no longer recreate the issue I describe in the OP, nevertheless, five times since yesterday, all scripts have stopped working, and it occurs randomly, just by itself, i.e. without me disabling TM it via the toolbar button menu(=TM remains enabled in the toolbar button menu).

The above happens to me in my everyday profile - I couldn't recreate it in the fresh profile with only TM and my ZIP, like in the issue I described here. This might be because, with the new version, the scripts stop working, not in a consistent, reproducible manner, but it seems to happen randomly.  

For reference, with the new version, I noticed that the scripts stopped working in the URL I sent you, as well as :

arogl commented 6 years ago

I have a similar issue, I have tested both the latest TM and beta in Firefox and a clean profile.

If I add 3 scripts for IMDB, they work when I install TM.

When I close FF and then restart and go back to IMDB, TM says 3 scripts running, but no changes are injected into IMDB web page.

I am trying to look at debugging and will attach when I find anything.

Update:

Tested on Version 63.0.3239.108 (Official Build) (64-bit) and Tampermonkey BETA 4.5.5663. I had no issues. Exported to Google Drive and tried on a new ff 57.0.2 profile with Tampermonkey BETA 4.5.5663, the scripts run fine, if I then close FF and then restart the scripts no longer work, even though the badge says they are running.

Update 2 (20171228): Completely uninstalling FF & leftover files and registry entries and going through the same process, it works the first time you install TM and then stop/start FF it fails. Install the latest beta it runs the scripts where it had previously failed. Stop/start FF and it no longer works.

I'll try debugging next.

derjanb commented 6 years ago

Unfortunately, I spoke too soon: although with with the new version I may no longer recreate the issue I describe in the OP, nevertheless, five times since yesterday, all scripts have stopped working, and it occurs randomly, just by itself, i.e. without me disabling TM it via the toolbar button menu

Hmm, this sounds like it could be related to #485

I have problems to reporduce this problem. Are the scripts working again after a refresh?

darkred commented 6 years ago

I have problems to reporduce this problem. Are the scripts working again after a refresh?

No, reloading the page (F5) doesn't help - restarting Firefox helped, though.  

Using FF 58 and latest TM beta 4.6.5694) with my everyday FF profile.

What has happened three times so far since yesterday is that the scripts may be working in a tab in a normal window (even after a reload/F5 on the page) but not in another tab, always in the same normal window ! i.e. all the scripts running in https://github.com/ would still work ok, and the MPIV script would still work in tabs different than the one that had imdb.com !!

Also at the same time, no script would run in the tabs with these URLs https://rarbgproxy.org/torrents.php (most notably this) http://www.imdb.com/title/tt0076759/ (most notably this) https://www.rottentomatoes.com/m/blade_runner_2049/ (most notably this)) https://www.youtube.com/watch?v=fElOwzSLbAU (most notably this)

Restarting Firefox fixed the issue.

Unfortunately there is no relevant entry in the Browser Console when this happens.

darkred commented 6 years ago

(Using FF 58 and latest TM beta 4.6.5694)

I'd like to add that restarting Firefox fixes the problem indeed, but not necessarily on the first restart: e..g. today my script Instagram - visible images counter (which runs on instagram profile pages, such as https://www.instagram.com/instagram/ ) randomly stopped working, and I restarted Firefox 5 times (with Firefox's session restore always having that instagram URL as the selected tab) and then eventually the script worked again.

darkred commented 6 years ago

The issue still occurs (scripts randomly stop working) in latest TM beta 4.6.5703 (using FF58),

darkred commented 6 years ago

Also, a thing I notice very frequently: when a script randomly stops in a page, e.g. [TS] Citrus GFork in https://greasyfork.org/en or Mouseover Popup Image Viewer in random pages, then, if, at session restore, the focused tab is the same as that when the script had stopped working and on which I had closed FF from the last session, then the issue is not fixed no matter how many times I restart Firefox. For the issue to be fixed, I usually have to focus a different tab (I open about:addons|'View Recent Updates' in a new tab) and then close and restart FF.

darkred commented 6 years ago

I get the following same error in Firefox Browser Console whenever scripts stop working in a tab -although scripts might still work in the other tabs- : (at that time the counter info badge in the TM toolbar button has no value for that tab)

Error: WebExtension context not found!               ExtensionParent.jsm:855:13

Using TM 4.6.5709 in FF 59.

darkred commented 6 years ago

In order to rule out the possibility that the cause the issue was caused because the TM userscript database in Firefox had might become corrupted for some reason, I even uninstalled Tampermonkey (i.e. incl. all installed scripts) in FF, and restored them from a ZIP backup of TM for Chrome (the same scripts, ~200), but unfortunately, the issue still occurs: scripts randomly stop working in some tabs.

I still get the same error in Browser Console when this happens:

Error: WebExtension context not found!               ExtensionParent.jsm:861:13

Using TM 4.6 in FF 60.

TempACount commented 6 years ago

I can confirm this happens on Chrome as well- been having this issue for months (but not for the maybe two years prior to then, with the same scripts). My assumption is that at some point an update to TamperMonkey introduced an element that, under certain conditions, causes the program to improperly configure or process.

darkred commented 6 years ago

TL;DR I'm positive that this issue is a duplicate of #211.


Details: I've noticed the following (TM 4.7.5788 beta in FF 60) : in e.g. this page https://greasyfork.org/en/users/2160-darkred?sort=updated commonly all scripts would stop working - most apparently the [TS] Citrus GFork (which completely reformats the page).

From the ZIP I've sent you, @derjanb, here are the active scripts for the above URL: 2018-06-07_220146

When all scripts would randomly stop working for the above tab/URL , no matter how many times I would reload the page, the problem wouldn't get fixed.

Of all the 14 scripts (in the screenshot) running, only 1 was running at document-start: GreaseBox .

I found that if I disabled it, then when I reloaded the page, all scripts would work ok, again.

I tried it multiple times (in other URLs too, where Greasebox was the only document-start script), and once the issue occurred, it was consistently fixed whenever I disabled that script, and occured again when I re-enabled it.

I'm positive that this issue is a duplicate of #211. Maybe, @derjanb you would like to take a look at the 'GreaseBox' script, too.


FWIW I was getting these two errors in Firefox's Browser Console, in both cases, i.e. when the issue occured, and when it was fixed:

Error: WebExtension context not found!  ExtensionParent.jsm:861:13
Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist.  background.js:3}
darkred commented 6 years ago

In addition to the above post, I've noticed that, even with GreaseBox is disabled, if at session restore the focused tab is the above page, https://greasyfork.org/en/users/2160-darkred?sort=updated then in most cases, the scripts in that tab (mainly '[TS] Citrus GFork') don't work, and the only way to fix is to close Firefox while having focus on a different URL, and restart Firefox. i.e. similar to my previous comment: https://github.com/Tampermonkey/tampermonkey/issues/477#issuecomment-370857498.

In other words, I believe that the issue is additionally related to #485, as you have already suggested.

arogl commented 5 years ago

Found another issue, on restart in FF 64/beta/nightly Tampermonkey BETA or normal does not always start on browser startup. I eventually narrowed it down to this script

W.A.R. Links Checker Premium

Turn the script off and Tampemonkey starts every time.

On chrome with the same scripts and settings this does not cause an issue. How can I help debug the startup issue?

phuclv90 commented 3 years ago

It's quite unfortunate that this 4-year-old bug is still not yet solved. But looks like it only appears on Windows. I've never seen the same issue in Firefox for mac

wvffle commented 3 years ago

But looks like it only appears on Windows.

I experience it on linux.

derjanb commented 2 years ago

Closing in favor of #1016