Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Fix error fetching favicon during background updates. #171

Merged
merged 1 commit into from
Oct 18, 2018
Merged

Conversation

Osmose
Copy link
Contributor

@Osmose Osmose commented Oct 16, 2018

Small fix for a potential error that I'm hitting on the fake product page from the favicon changes.

@Osmose Osmose requested a review from biancadanforth October 16, 2018 20:40
Copy link
Collaborator

@biancadanforth biancadanforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R(+WC?) Thanks Osmose for taking a moment to try and address this error. I'm not sure what error you're seeing, but the error I'm seeing doesn't go away with this patch. I suggest a minor change that removes the error from my end.

@@ -25,7 +25,7 @@ export async function handleExtractedProductData(contentExtractedProduct, sender
// Fetch the favicon, which the content script cannot do itself.
const extractedProduct = {
...contentExtractedProduct,
vendorFaviconUrl: sender.tab.favIconUrl,
vendorFaviconUrl: sender.tab ? sender.tab.favIconUrl : '',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is exactly the error you were seeing, but this is the error I have been seeing, and I am still seeing in this patch:

[Exception... "Favicon at "http://www.mkelly.me/favicon.ico" failed to load: Not Found."  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: resource:///modules/FaviconLoader.jsm :: onStopRequest :: line 154"  data: no]

I think this is because sender.tab.favicon can also be undefined in the case that the tab is still loading (though the docs say it should return '') or the site (like the fake product page) doesn't have a favicon.

If I change it to:

Suggested change
vendorFaviconUrl: sender.tab ? sender.tab.favIconUrl : '',
vendorFaviconUrl: (sender.tab && sender.tab.favIconUrl) ? sender.tab.favIconUrl : '',

I no longer see the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is exactly the error you were seeing,

I was seeing both an error that sender.tab was null, and the error you're seeing. My original PR fixed the former, but not the latter. I thought the latter was just an error that all pages without favicons gave and was unavoidable. Interesting to find that it wasn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this change out locally and it doesn't remove the error.

I think this is because sender.tab.favicon can also be undefined in the case that the tab is still loading (though the docs say it should return '') or the site (like the fake product page) doesn't have a favicon.

The error you're seeing isn't an error about the value being undefined. The error message says that it failed to load favicon.ico from the webpage; it's not an error in how we're accessing the attribute, it's an error in loading the icon file. As long as we're accessing the favicon for a page that doesn't have one, that error will show up in the browser console.

For what it's worth, I'm not seeing any behavior differences because of it. Can you verify that you're seeing breakage from specifically that error?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it doesn't look like it breaks anything; it continues executing the handleExtractedProductData code downstream of the error.

@biancadanforth
Copy link
Collaborator

@Osmose I think this error is actually breaking price updates currently, so we may want to tag this commit and push a new version of the extension after merging? I'm working on #166 and I didn't see any price alerts for the fake product page until I made this change (my recommended change in particular).

@Osmose
Copy link
Contributor Author

Osmose commented Oct 18, 2018

I'm working on #166 and I didn't see any price alerts for the fake product page until I made this change (my recommended change in particular).

This PR fixes price alerts for me as well, although the extra change you suggested doesn't appear to have an effect (see my pending comment above).

@Osmose Osmose merged commit a198923 into master Oct 18, 2018
@Osmose Osmose deleted the fix-favicon branch October 18, 2018 22:12
@Osmose
Copy link
Contributor Author

Osmose commented Oct 18, 2018

Thanks for the review! I landed this so we could get out the extraction fix, but we may still followup with another fix if the other error turns out to be a problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants