etienne-martin / svg-to-img

A node.js library to convert SVGs to images built with Puppeteer.
MIT License
53 stars 22 forks source link

Error: Protocol error (Runtime.evaluate): Target closed. #22

Open chojje opened 4 years ago

chojje commented 4 years ago

Sometimes when I try to convert multiple (50+) svg files simultaneously, I get the following error:

Error: Protocol error (Runtime.evaluate): Target closed.
    at /home/sawent/Documents/Utveckling/repos/ncc-calculation/node_modules/puppeteer/lib/Connection.js:196:56
    at new Promise (<anonymous>)
    at CDPSession.send (/home/sawent/Documents/Utveckling/repos/ncc-calculation/node_modules/puppeteer/lib/Connection.js:195:12)
    at ExecutionContext.evaluateHandle (/home/sawent/Documents/Utveckling/repos/ncc-calculation/node_modules/puppeteer/lib/ExecutionContext.js:61:77)
    at ExecutionContext.evaluate (/home/sawent/Documents/Utveckling/repos/ncc-calculation/node_modules/puppeteer/lib/ExecutionContext.js:46:31)
    at Frame.evaluate (/home/sawent/Documents/Utveckling/repos/ncc-calculation/node_modules/puppeteer/lib/FrameManager.js:299:20)
    at processTicksAndRejections (internal/process/task_queues.js:94:5) {
  message: 'Protocol error (Runtime.evaluate): Target closed.'
}

It seems that increasing the timeout time in scheduleBroswerForDestruction() resolved the issue for me.

etienne-martin commented 3 years ago

Are you converting them all in one go with a Promise.all or something? If so I'd do the conversion sequentially instead.