Szpadel / chrome-headless-render-pdf

223 stars 67 forks source link

Chrome headless instances remain running. #6

Closed lucasowens closed 7 years ago

lucasowens commented 7 years ago

When calling generateSinglePdf from express.js I am seeing chrome instances get spawned but never destroyed, they remain running in the background. It appears the the kill command is being called but the chrome instances are still using memory. I am on windows 10 chrome build Version 60.0.3112.78 (Official Build) beta (64-bit), any ideas?

/* global */
'use strict';

const RenderPDF = require('chrome-headless-render-pdf');

module.exports = function (cb) {
    const htmlFileName = 'file://page.html';

    const pdfName = Date.now() + '_page.pdf';

    RenderPDF.generateSinglePdf(htmlFileName, pdfName, { chromeBinary: 'chrome' }).then(resp => {
            cb(null, pdfName);
        })
        .catch(err => {
            cb(err);
        });
};
const express = require('express')
const app = express()
const render = require('./render4');

app.get('/', function (req, res) {
    render((err, resp) => {
        res.send(resp);
    });
})

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})
Szpadel commented 7 years ago

Hello, Can you check if #8 will solve your issue?

you can check that by cloning this branch and then executing npm run build and use npm link to lint that to your project.

lucasowens commented 7 years ago

This fixed the problem. Thank you very much for the quick turn around. I am still able to get a zombie chrome when a request fails. I will continue looking for a solution to this. Please let me know if you have any suggestions.