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

240
Visualizações
Firefox extension can recieve messages via native messaging, but sending messages doesn't seem to work

I'm working on a Firefox extension with a Node.js script as a native messaging host. Messages sent to the extension from the script are recieved as expected, but every method I have tried to listen for messages from the extension have failed.

I have tried using stdin:

process.stdin.on('readable', function() {
  let message = JSON.stringify("hello");
  sendMessage(`{"test": "${message}"}`);
});

This works fine if I run the script from the command line but it will never pick up messages sent from the extension itself.

I have also tried the npm native-messaging host protocol, based closely on the example:

var sendMessage = require('native-messaging')(handleMessage)
 
function handleMessage (req) {
    fs.writeFile('test.txt', req.message, err => {
    if (err) {
        console.error(err);
    }
    // file written successfully
    }); 
    sendMessage({message: "pong", body: 'hello from nodejs app'});
}

This also yields no result.

I have tested both methods and neither of these functions seem to ever be called, no matter how many times I send a message from the extension, and no errors are thrown.

I don't believe this is a problem with the manifest or the registry keys, because messaging seems to work fine one way.

Why are my messages not being received by the script?


Native Messaging documentation by MDN

npm Native Messaging

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