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

[webext-bridge] No handler registered in 'content-script' to accept messages with id 'get-name' #144

Open
5 tasks done
capoia opened this issue Jun 6, 2023 · 1 comment

Comments

@capoia
Copy link

capoia commented Jun 6, 2023

Describe the bug

Hello, I need to send and receive content script messages with .vue files and vice versa.
But whenever I try, I can't make my content script communicate with the .vue, and I even tried options, and I get the same error:
CleanShot 2023-06-06 at 12 36 25

Reproduction

https://stackblitz.com/edit/github-hcxykr

System Info

System:
    OS: macOS 13.4
    CPU: (8) arm64 Apple M1
    Memory: 84.78 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.0/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
  Browsers:
    Chrome: 114.0.5735.106
    Firefox: 113.0.2
    Safari: 16.5

Used Package Manager

yarn

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@opeadeyomoye
Copy link

For others that may run into a similar error, you may simply need to check that your sendMessage / onMessage import statements specify the right "endpoints" since these endpoints indicate the source and destination of each message according to webext-bridge's documentation.

i.e. within e.g. src/contentScripts/views/Sample.vue

import { ... } from 'webext-bridge/content-script'

While in your background script(s) it'll be:

import { ... } from 'webext-bridge/background'

and so on (other endpoints are popup, options, devtools and window)


Looks like you made your imports correctly @capoia . Do you think the error could've come up because you send the message in contentScripts/index.ts before the listener gets registered in contentScripts/App.vue (since the vue app is only initialized many lines after the sendMessage() call)?

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

2 participants