Native Messaging works fine for me, and then it doesn't

I’m trying to build an extension which will get a pdf upload from a specific webpage and, through native messaging, will send to a java application, responsible for digital signing the ‘uploaded’ file using a USB token (PKCS#11) and saving it locally.

Everything seems to work fine at the beginning, but the application just shuts down out of the blue, in the middle of some code execution without exception being thrown.

I think the problem might be with some Firefox specificity I’m missing, as the application runs OK when tested on Chrome.

Here are my manifest file, background and content scripts for scrutiny:


  "name": "docsigner",
  "version": "1.0",
  "manifest_version": 2,
  "description": "Extension interacting with Native Messaging and localhost.",
  "browser_specific_settings": {
    "gecko": {
      "id": "",
      "strict_min_version": "50.0"
  "content_scripts": [
      "matches": [
      "js": [
  "background": {
    "scripts": [
  "permissions": [


function onResponse(response) {
    console.log("Received " + JSON.stringify(response));

function onError(error) {
    console.log("Error: " + JSON.stringify(error));

function processOperation(data) {
    port = chrome.runtime.connectNative("docsigner");

function processAnotherOperation(data) {
    var sending = chrome.runtime.sendNativeMessage("docsigner", data);
    sending.then(onResponse, onError);



    var extId = "";

    function upload() {

        var file = document.getElementById("file").files[0];

        var reader = new FileReader();

        reader.onload = function (e) {

            console.log("enviando: " +;

            chrome.runtime.sendMessage(extId, { content: }, function (response) {






    document.getElementById("upload-button").addEventListener("click", upload);

Ok, so I managed to log the error on Firefox Debug:

Native application tried to send a message of 808595506 bytes, which exceeds the limit of 1048576 bytes.

It’s weird, because analyzing the native application log, it didn’t even get to the point where it was supposed to send back a response.

It must have written something to its stdout, which lead to Firefox trying to parse it as a native message and the length magic bits turned out to that number above?

I guess you’re right. It looks like one of my dependencies logs to stdout. I’ll do some tests. Thank you!