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

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. #67

Open
hoangvu12 opened this issue Jul 17, 2023 · 3 comments

Comments

@hoangvu12
Copy link

I'm trying to post message from web to content scripts, but for some reason it keeps showing error Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

image

Here is my content script (index.ts):

const handleDOMLoaded = async () => {
  import("./content");
};

if (document.readyState === "loading") {
  document.addEventListener("DOMContentLoaded", handleDOMLoaded);
} else {
  handleDOMLoaded();
}

content.ts:

import { allowWindowMessaging } from "webext-bridge/content-script";

allowWindowMessaging("test");

I have no idea why it causes that, it just happens whenever I call the allowWindowMessaging function.

@songpengyuan
Copy link

I also have this problem.

@zikaari
Copy link
Collaborator

zikaari commented Sep 25, 2023

Can you try not importing asynchronously? It might have something to do with that

@songpengyuan Can you also share your setup?

@hoangvu12
Copy link
Author

Can you try not importing asynchronously? It might have something to do with that

@songpengyuan Can you also share your setup?

I can't import webext-bridge without import another file asynchronously.

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