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

Trending nav item is repeating in header #479

Closed
hkdobrev opened this issue Jun 6, 2017 · 20 comments
Closed

Trending nav item is repeating in header #479

hkdobrev opened this issue Jun 6, 2017 · 20 comments
Labels

Comments

@hkdobrev
Copy link
Contributor

hkdobrev commented Jun 6, 2017

image

Steps to reproduce:

  1. Go to https://github.com/sindresorhus/refined-github It's added twice
  2. Click on a sub-repo navigation item - e.g. Issues tab.

This has been introduced relatively recently on master.

@hkdobrev hkdobrev added the bug label Jun 6, 2017
@fregante
Copy link
Member

fregante commented Jun 7, 2017

I cannot reproduce on master. This sounds strange because

  • that function is called once (no domready or anything)
  • the waiter is being a promise (which resolves once)
  • elementReady only selects one element. so $().after() is not adding more of them at the same time.

Not sure how that's happening. Perhaps it's related to #450 and you have a custom domain manually added as a test for that. Try reinstalling it to reset that (toggle/reload doesn't work). Also make sure that it's being built and it's not an old version.

@hkdobrev
Copy link
Contributor Author

hkdobrev commented Jun 7, 2017

It is indeed quite strange. The function is actually called twice and it's fixed when I remove both async and await. Would reinstall and report back.

@fregante
Copy link
Member

fregante commented Jun 7, 2017

It's it's called twice then the script is being injected twice, probably. Stick a console.log at the bottom of content.js; this might still be an issue for GHE (although at that point we can just wait for GHE users to report it)

@fregante
Copy link
Member

fregante commented Jun 7, 2017

Do you have multiple extensions loaded? 😃

@busches
Copy link
Member

busches commented Jun 15, 2017

I was able to have this occur today too.
image
Running latest master, confirmed I do not have two extensions loaded. Additionally the Trending item is being added with the back button as well, so each time I click back, two new Trending items are added.

@fregante
Copy link
Member

fregante commented Jun 15, 2017

ahhhh I think the dynamic script injector's ping receiver got lost. Try this #492

@fregante
Copy link
Member

New issue report here: #492 (comment)

@fregante
Copy link
Member

I saw this issue once I re-enabled the AMO version, but then I reloaded the page and it stopped appearing (for now)

It might happen once.

@SimenB
Copy link

SimenB commented Jun 24, 2017

What's AMO? 😅

@fregante
Copy link
Member

Mozilla Addons site 😃

@OmgImAlexis
Copy link

It's getting worse. Yesterday I had 20 of them. 😨

screen shot 2017-06-25 at 12 39 37 pm

@fregante
Copy link
Member

fregante commented Jun 25, 2017

I'm having a hard time figuring this out. Surprisingly, chrome.permissions doesn't include github.com (because in manifest.json, github.com is only specified in content_scripts but not permissions), so the injector should be stopped pretty early and it should not run at all.

Can you inspect the background page and run this code in its console?

chrome.permissions.getAll(console.log);
chrome.tabs.onUpdated.addListener((tabId, ignore, {url}) => console.log(url));

Then open github.com and look back in the background page's console. It should look like this:

screen shot 2017-06-25 at 12 04 48

origins: Array(0) and then a lot of undefined

@fregante
Copy link
Member

Are the Trending links consistently there? All the time every time?

If so, try this:

  1. visit a repo
  2. paste this in the console:
    chrome.runtime.onMessage.addListener(request => console.log(request, chrome.runtime.id));
  3. visit the Issues tab

Nothing should appear in the console, the page should be loaded via ajax (i.e. the console should still contain what you pasted)

@OmgImAlexis
Copy link

screen shot 2017-06-25 at 11 49 00 pm

The trending links seem to start off on 1 or 2 and then add another on the first time I load another section within the repo like the issues/PRs/Releases, etc. e.g. issues only gives 1 more but going to 3 repos and clicking issues each time adds 3.

screen shot 2017-06-25 at 11 52 07 pm

@fregante
Copy link
Member

fregante commented Jun 25, 2017

I'll add some logging at every step and push to Chrome so we can get more details.

@busches
Copy link
Member

busches commented Jun 28, 2017

An easy way to work around this is to add the same code we have for most other items we add to the dom and check for it's existence before adding it. Doesn't solve the root cause of why the extension is running twice, but if it's an odd edge case, it may be worth the time savings of solving it the quick and easy way, especially since we use that pattern for everything else.

@fregante
Copy link
Member

I'd rather not do that because it'd push the real problem under the rug, deprioritizing the issue. You don't want an extension to run 10 times.

@paulmolluzzo
Copy link
Contributor

I'd rather not do that because it'd push the real problem under the rug, deprioritizing the issue. You don't want an extension to run 10 times.

While that's fair, I think it's worth fixing the issue as best as we can immediately and then addressing the larger issue without this clear bug in the way.

I think @busches suggestion of checking for the existence of the element before adding it is a fine fix for now (we're doing it elsewhere already). Later when we have time to circle back on the underlying issue we can also remove the unnecessary DOM checks for this element and others when we have a better fix.

@SimenB
Copy link

SimenB commented Jun 28, 2017

+1 for quick fix, it's really annoying... Even though I get an itch by treating symptoms and not the underlying issues

@busches
Copy link
Member

busches commented Jun 28, 2017

@bfred-it I'm not suggesting we ignore the issue all together, only that we put in the workaround as it's super annoying, as @paulmolluzzo and @SimenB mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

7 participants