Receiving end does not exist.
Hey there, new Plasmo user here. I'm trying to pull some information from the DOM (of the currently active tab) and display it in my extension. Should be simple...
I'm getting
Error: Could not establish connection. Receiving end does not exist.
when calling sendToContentScript
.
I couldn't find any documentation for this function, so hoping you can point me to the right direction. I refreshed all tabs/ reloaded the extension, so I think the error is due to me not understanding how messaging in Plasmo works..
popup.tsx
contents/getFields.ts
10 Replies
Turns out it had to be
getFields.tsx
not .ts
I'm getting this same error right now as well. I tried copying what you posted, I also tried changing my
content/getContent.ts
to .tsx
like you suggested.
Any other suggestions for getting this to work?
contents/getContent.tsx
popup.tsx
I figured it out... Apparently you need new tabs, not just a refresh of old tabs.. OOF. Thanks for the code and suggestion of using .tsx
@samsonGave +1 Rep to @samson
@Brandon has reached level 1. GG!
Hey there, I was wondering if you encountered the error where the console.log("result is", res) returns a "result is" undefined?
@nayrbhpdf5D has reached level 3. GG!
This post deserves gold medal. We need more info on the doc for future users 🙂
Couldn't agree more
@Omen has reached level 1. GG!
Anyone have the latest 2024 solution to this?
Error during analysis: Error: Could not establish connection. Receiving end does not exist.
src/components/pageSelector.tsx
This is a similar function to the ones above, where a button is clicked to trigger the contentScript. The only difference is I'm doing this from a different component and not the popup.tsx:
try {
const response = await sendToContentScript({
name: "analyzePage"
})
src/contents/analyzePage.tsx
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
const {name} = req
if (name === "analyzePage") {
console.log("AnalyzePage message received, starting analysis.")
const patientLabel = await analyzePage()
console.log("patient label:", patientLabel)
res.send({ patientLabel })
}
}
I just get the error 'receiving end does not exist', can anyone shed some light.