Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

391
Visualizações
Sending message from a page to Chromium (Edge) extension returns an error

There're a number of similar questions here, but none of them seem to apply to sending messages from a regular web page directly to an extension.

Chrome docs state that this is possible without using content scripts.

I've allowed external callers in manifest.json:

  "externally_connectable": {
    "matches": [
      "http://localhost/*",
      "http://host.local/*"
    ]

But performing a call as follows yields Uncaught Error: Attempting to use a disconnected port object:

port = chrome.runtime.connect(editorExtensionId);
port.postMessage(editorExtensionId, { connect: true },
    function (response) {
        console.log(response.message);
    });

On the other hand, sending messages directly works via chrome.runtime.sendMessage(editorExtensionId, ...) , but in this case I can only reply once, as there's no port with a longer lifetime.

Inside the extension - in background.js - I'm using chrome.runtime.onMessageExternal.addListener. Strangely, I usually get another error message after the first one: Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

The page is hosted on http://host.local in both cases.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda