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

runtime.connect() called from a webpage must specify an Extension ID #207

Closed
alex-polunochev-zz opened this issue May 9, 2019 · 6 comments

Comments

@alex-polunochev-zz
Copy link

webext-redux version 2.0.2
Chrome Version 74.0.3729.131 (Official Build) (64-bit)

Following the instructions from Readme.
Configured the store in the background - can dispatch actions and can see store getting updated.
Moving to the UI. Calling const store = new Store() from the content script injected to the webpage. It results in an error:

Screen Shot 2019-05-08 at 10 54 02 PM

or

Uncaught TypeError: Error in invocation of runtime.connect(optional string extensionId, optional object connectInfo): chrome.runtime.connect() called from a webpage must specify an Extension ID (string) for its first argument.
    at new Store (Store.js:86)

Looks like a reincarnation of #134

When as an experiment I pass the extension id (copied value from chrome://extensions tab) in as

const store = new Store({ extensionId: 'oqzqcvjbblablablablauwhodbbheeeuin' })

I am getting a different error:

Store.js:90 Uncaught TypeError: Cannot read property 'addListener' of undefined
    at new Store (Store.js:90)

Am I doing it right? Any clues?

@alex-polunochev-zz
Copy link
Author

Based on this thread #47 I implemented an alternative communication channel using onMessageExternal, extensionId parameter for chrome.runtime.sendMessage and externally_connectable rule in manifest file. Now the messages go through. But without using Redux.

With the same manifest configuration the errors posted above still persist when I try to create new Store (with or without extensionId parameter).

@godd9170 could you share any additional information on what else you might have done to fix your problem (#47) besides what was published later in PR #49 and what I listed in the beginning of the post?

@godd9170
Copy link
Contributor

godd9170 commented May 9, 2019

@alex-polunochev I'm afraid I don't remember much from that thread. I do know that #49 introduced everything I needed and passing that externalId allowed for communication from the .js that was injected into the page.

What do you mean exactly with But without using Redux?

@alex-polunochev-zz
Copy link
Author

@godd9170 Thanks anyway!
I meant there that finally I reached the point where my injected React component can send messages to background. But that unfortunately I wasn't able to use this library that brings Redux store and actions to facilitate a better, more efficient type of communication and storage.

@tshaddix
Copy link
Owner

Hey @alex-polunochev - sorry that you're having issues.

Have you tried removing this.extensionId from the call in store.js here? I'm wondering if the latest version of chrome does not like the "null" extension Id that we pass in the default props.

That said, I haven't seen the error on my side.

@alex-polunochev-zz
Copy link
Author

@tshaddix I actually figured out the problem and should close this ticket, as there's no problem with webext-redux.
I was using the 3rd party boilerplate code for my extension that was injecting the script into the hosting web page via a chain of calls which led to breaking of the execution context. Thus chrome.runtime was no longer providing an object to work with. After simplifying that execute-a-script-to-execute-a-script-to-inject-a-react-script flow and avoiding unneccessary steps, I managed to gain the control of the context back. Using webext-redux without problem now.

@tshaddix
Copy link
Owner

Excellent - great!

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

No branches or pull requests

3 participants