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

187
Visualizações
Duplicated calls for resource with node-canvas and jsdom

I'm getting duplicated calls for a resource when it's added through a script as an image using jsdom and node-canvas.

I believe there's some kind of interaction between jsdom and canvas that performs the call to that endpoint twice, I don't know if someone can help me to configure this properly but I need only one call.

const jsdom = require('jsdom');
const { JSDOM } = jsdom;

const options = { 
     runScripts: "dangerously", 
     url: `https://localhost:8800`,
     resources: "usable" 
};

new JSDOM(`
  <html>
    <head><script src="https://code.jquery.com/jquery-3.5.1.min.js"></script></head>
    <body>
      <div id="my_img"></div>
      <script>
        var src_img = document.getElementById("my_img");
        var testimg = document.createElement("img"); 
        testimg.src = "https://revistahsm.com/wp-content/uploads/2018/08/Fiestas.png"; // example img
        testimg.width = 0;
        testimg.height = 0;
        src_img.appendChild(testimg);
      </script>
    </body>
  </html>
`, options);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I asume it has to do with the resizing of the image, "after" it has be loaded. Maybe because of a "redraw", or so. (the browser canvas does this, if I remember correct). I just tested this theory, so if you reorder some lines like this

...
testimg.width = 0;
testimg.height = 0;
testimg.src = "http://localhost:8080/Fiestas.png"; // example img
src_img.appendChild(testimg);
...

the image should be loaded only once. I just tried it, and it worked, but I don't have documentation or Code prove, yet. Will Update the answer if/when I find the prove to this (working)-theory.

about 4 years ago · Juan Pablo Isaza Relatório
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