Error: spawn */chrome-linux/chrome EAGAIN on puppeteer launch
See original GitHub issueIssue description:
An error occurred in my production environment and then my program exist ^_^, the error stack is as follows:
Error 1:
TypeError: input.on is not a function
at new Interface (readline.js:174:11)
at Object.createInterface (readline.js:64:10)
at Promise (/users/hacker/fb/mimi/mimi/node_modules/puppeteer/lib/Launcher.js:327:25)
at Promise (<anonymous>)
at waitForWSEndpoint (/users/hacker/fb/mimi/mimi/node_modules/puppeteer/lib/Launcher.js:326:10)
at Launcher.launch (/users/hacker/fb/mimi/mimi/node_modules/puppeteer/lib/Launcher.js:166:41)
at module.exports.launch (/users/hacker/fb/mimi/mimi/node_modules/puppeteer/lib/Puppeteer.js:36:27)
at runScript (/users/hacker/fb/mimi/mimi/scripts/index.js:61:37)
at keepaliveDefaultStratery (/users/hacker/fb/mimi/mimi/beat/keepAliveSchedule.js:218:22)
at joinCore (/users/hacker/fb/mimi/mimi/beat/keepAliveSchedule.js:180:20)
at main (/users/hacker/fb/mimi/mimi/beat/keepAliveSchedule.js:117:28)
at <anonymous>
Error 2: by process.nextTick
Error: spawn /users/hacker/fb/mimi/mimi/node_modules/puppeteer/.local-chromium/linux-609904/chrome-linux/chrome EAGAIN
at _errnoException (util.js:1041:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
at onErrorNT (internal/child_process.js:374:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
Error analysis:
- An EAGAIN error occurred when lunch puppeteer, It will be return and does not execute the following code, such as setting stderr for child_process object (chromeProcess object). code
- waitForWSEndpoint method will use the stderr property. At this time, The stderr property is undefined but will call stderr.on method, So the error 1 will be occurred. code
- child_process.js will trigger an error by process.nextTick, Puppeteer does not listening error event because Error 1. So the error didn’t catch. Program exist. code
Solution
Set the listen error event before chromeProcess.stderr. Allowing chromeProcess to handle error events.
const exitListenerId = helper.addEventListener(chromeProcess, 'exit', () => onClose());
const errorListenerId = helper.addEventListener(chromeProcess, 'error', error => onClose(error))
const rl = readline.createInterface({ input: chromeProcess.stderr });
let stderr = '';
const listeners = [
helper.addEventListener(rl, 'line', onLine),
helper.addEventListener(rl, 'close', () => onClose()),
exitListenerId,
errorListenerId
];
const timeoutId = timeout ? setTimeout(onTimeout, timeout) : 0;
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Error: Failed to launch the browser process puppeteer
What works for me was to download chromium manually sudo apt-get install chromium-browser . And then, tell Puppeteer where chromium is located :...
Read more >Troubleshooting - Puppeteer
Chrome headless doesn't launch on UNIX. Make sure all the necessary dependencies are installed. You can run ldd chrome | grep not on...
Read more >Error: Failed to launch the browser process puppeteer-node.js
Error : Failed to launch the browser process! spawn /home/user/PuppeteerTests/node_modules/puppeteer/.local-chromium/linux-737027/chrome-linux/chrome ENOENT.
Read more >Failed to launch the browser process! puppeteer - YouTube
node_modules/ puppeteer /.local-chromium/linux-901912/ chrome-linux/chrome : error while loading shared libraries: libatk-bridge-2.0.so.0: ...
Read more >PuppeteerJS Execution (or other Web Scraping)
ERROR: Failed to launch the browser process! spawn /root/.n8n/nodes/node_modules/puppeteer/.local-chromium/linux-1002410/chrome-linux/chrome ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nicoandmee this error might happen when Puppeteer fails to launch Chrome. It might be because the host env runs out of file handles limit or maybe something else - I’m not sure yet, but it’d be nice to re-create this locally to see what’s going on.
M facing the error
TypeError: input.on is not a function
in red hat 7.8 and have made the changes as suggested in waitForWSEndpoint Still facing the same issueError: input.on is not a function\n at new Interface (readline.js:207:11)\n at Object.createInterface (readline.js:75:10)\n at Promise (/apps/cbqpms/credence/microservices/reporting-server/node_modules/puppeteer/lib/Launcher.js:329:27)\n at new Promise (<anonymous>)\n at waitForWSEndpoint (/apps/cbqpms/credence/microservices/reporting-server/node_modules/puppeteer/lib/Launcher.js:326:12)\n at Launcher.launch (/apps/cbqpms/credence/microservices/reporting-server/node_modules/puppeteer/lib/Launcher.js:170:41)