This works perfectly when running once. However, when I try to run multiple instances at the same time, one process gets stuck halfway through and the other returns error code 124. I’ve already tried setting headless to false and using browserInstance.newPage() with new context as suggested in documentation, but the issue persists. How can I run multiple puppeteer instances concurrently without conflicts?
Error 124 is a timeout issue with concurrent processes. You’re hitting resource contention - multiple browser instances fighting over the same system resources. Don’t launch separate browsers for each task. Try a connection pool instead: one browser with multiple pages, or queue the requests to run sequentially. Also bump up your PHP exec timeout values and add proper error handling. I had luck with a file-based locking system that prevents multiple instances from starting at once, then processes them quickly one after another. Kills the resource conflicts and still gives decent performance for batch screenshots.
yeah, classic puppeteer concurrency issue. you’re spawning multiple browser processes that devour memory. don’t launch new browsers each time - reuse one browser instance and just open new tabs. check your system limits too since puppeteer’s resource-hungry. add delays between launches or use a semaphore to cap concurrent executions at 2-3 max.
You’re launching multiple browser instances at once - that’s what’s causing the process conflicts and eating up your resources. Set up a singleton pattern instead. Keep one browser running and reuse it for all PHP requests. I’d run a long-lived Node.js service that keeps the browser open and takes screenshot requests through HTTP or sockets. This kills the overhead from constantly launching new browsers and stops that error 124. I’ve done this for high-volume screenshot work - just queue your requests properly and restart the browser every so often to clear memory leaks.