Heroku Puppeteer launches once then fails on subsequent runs

Puppeteer on Heroku starts successfully after a fresh build but then fails on later runs using Node v18 and a custom Puppeteer buildpack. Try this snippet:

async function bootPup() {
  const instance = await pupModule.initialize({
    args: ['--no-sandbox', '--disable-setuid-sandbox']
  });
  return instance;
}

Considering similar issues I faced recently, it seems that the failing subsequent executions are often linked to how system resources are managed. I discovered that ensuring complete browser shutdown after each use made a significant difference. Specifically, I had to incorporate a cleanup routine where both pages and browser instances were explicitly closed. This prevented resource leaks, which eventually hampered further launches. Tracking the error logs also provided insights into potential memory constraints and unused processes accumulating over time. Evaluating these practices may help resolve your situation.