I have the whole thing working locally but fails as soon as its on heroku server.
implementation
await pdf.create(pdfTemplate(data)).toStream(async function (err, stream) {
await stream.pipe(fs.createWriteStream(`${req.body.phone}.pdf`));
const params = {
Bucket: "icon-path-bucket",
Body: stream,
Key: req.body.phone,
contentType: "application/pdf"
}
Error(in production)
2023-06-17T10:16:06.144530+00:00 app[web.1]: await stream.pipe(fs.createWriteStream(`${req.body.phone}.pdf`));
2023-06-17T10:16:06.144530+00:00 app[web.1]: ^
2023-06-17T10:16:06.144530+00:00 app[web.1]:
2023-06-17T10:16:06.144531+00:00 app[web.1]: TypeError: Cannot read properties of undefined (reading 'pipe')
The html-pdf has been deprecated, so I was able to use
puppeteerwith the heroku build packhttps://github.com/jontewks/puppeteer-heroku-buildpack. The implementation is below:Without the heroku build pack, the it will still fail on the server even if it works locally. Or the correct configuration for your server: see
https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#could-not-find-expected-browser-locally