tshaddix / webext-redux

A set of utilities for building Redux applications in Web Extensions.
MIT License
1.22k stars 180 forks source link

Firefox Error in wrapStore.js #209

Closed alexelisenko closed 5 years ago

alexelisenko commented 5 years ago

I have a web extension that uses wrapStore in the background. As soon as the extension is added, the debug console shows the following error:

Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist.

This is coming from wrapStore.js line 204

which seems realted to:

browserAPI.tabs.sendMessage(tab.id, {
    action: 'storeReady'
});

Has anyone come across this issue? Any insight would be greatly appreciated.

alexelisenko commented 5 years ago

After some more debugging, I see that this error is related to not having any onMessage listeners registered in any content scripts. The extension im working on does not need any content scripts when first initialized, and this error is thrown before the popup is ever created. My workaround was to comment out the storeReady messages to all tabs in the wrapStore method.

Could this be made into configuration option perhaps?

tshaddix commented 5 years ago

Hey @alexelisenko - ah - makes sense. Because we are connecting directly to the tab it wants to make sure we know no-one is listening on the other side.

Perhaps we can simply "check" the error and that should take care of the warning via the response callback param (https://developer.chrome.com/extensions/tabs#method-sendMessage). I can submit a PR for that.

alexelisenko commented 5 years ago

That looks like it would also work. Thanks.

tshaddix commented 5 years ago

Released in 2.1.1