pofider / phantom-html-to-pdf

Highly scalable html to pdf conversion using phantom workers
MIT License
159 stars 33 forks source link

occasionally I get "phantom manager could not start all workers" error #107

Open darkopetreski opened 5 years ago

darkopetreski commented 5 years ago

I am using phantom-html-to-pdf version 0.5.6 on debian 9 to generate pdf files from html. Occasionally I get the following error, and cannot see any pattern when it happens. Just it happens sometimes. Any idea what could be the problem and how to fix it ?

{ Error: phantom manager could not start all workers.. at /var/www/dev/backend/node_modules/phantom-workers/lib/phantomManager.js:66:47 at /var/www/dev/backend/node_modules/phantom-workers/lib/phantomWorker.js:117:24 at /var/www/dev/backend/node_modules/phantom-workers/lib/phantomWorker.js:140:20 at Socket.<anonymous> (/var/www/dev/backend/node_modules/phantom-workers/lib/checkPortStatus.js:45:9) at Socket.emit (events.js:198:13) at TCP._handle.close (net.js:606:12) workerErrors: [ Error: Unable to reach phantomjs web server. at /var/www/dev/backend/node_modules/phantom-workers/lib/phantomWorker.js:140:23 at Socket.<anonymous> (/var/www/dev/backend/node_modules/phantom-workers/lib/checkPortStatus.js:45:9) at Socket.emit (events.js:198:13) at TCP._handle.close (net.js:606:12), Error: Unable to reach phantomjs web server. at /var/www/dev/backend/node_modules/phantom-workers/lib/phantomWorker.js:140:23 at Socket.<anonymous> (/var/www/dev/backend/node_modules/phantom-workers/lib/checkPortStatus.js:45:9) at Socket.emit (events.js:198:13) at TCP._handle.close (net.js:606:12) ] } /var/www/dev/backend/htmlToPdf.js:46 pdf.stream.pipe(output).on('finish', () => process.exit()); ^ TypeError: Cannot read property 'stream' of undefined at /var/www/dev/backend/htmlToPdf.js:46:17 at /var/www/dev/backend/node_modules/phantom-html-to-pdf/lib/serverStrategy.js:42:20 at /var/www/dev/backend/node_modules/phantom-html-to-pdf/lib/serverStrategy.js:22:48 at Array.forEach (<anonymous>) at /var/www/dev/backend/node_modules/phantom-html-to-pdf/lib/serverStrategy.js:22:25 at /var/www/dev/backend/node_modules/phantom-workers/lib/phantomManager.js:68:28 at /var/www/dev/backend/node_modules/phantom-workers/lib/phantomWorker.js:117:24 at /var/www/dev/backend/node_modules/phantom-workers/lib/phantomWorker.js:140:20 at Socket.<anonymous> (/var/www/dev/backend/node_modules/phantom-workers/lib/checkPortStatus.js:45:9) at Socket.emit (events.js:198:13)

pofider commented 5 years ago

Is it an option for you to use dedicated-process strategy? It should help https://github.com/pofider/phantom-html-to-pdf#global-options

darkopetreski commented 5 years ago

Thank you for the advice, I will give it a try :)

rspacecode commented 5 years ago

I also have same issue please help me if any one fixed it, I am creating .exe of node and facing this error, with source code its working but not working with executable. I also tried this : https://github.com/pofider/phantom-html-to-pdf#global-options but same result

{ Error: phantom manager could not start all workers.. at E:\snapshot\fileserver\node_modules\phantom-workers\lib\phantomManager.js:65:47 at E:\snapshot\fileserver\node_modules\phantom-workers\lib\phantomWorker.js:103:24 at E:\snapshot\fileserver\node_modules\phantom-workers\lib\phantomWorker.js:128:20 at Socket. (E:\snapshot\fileserver\node_modules\phantom-workers\lib\checkPortStatus.js:45:9) at Socket.emit (events.js:189:13) at TCP._handle.close (net.js:597:12) workerErrors: [ { Error: spawn E:\snapshot\fileserver\node_modules\phantom-workers\node_modules\phantomjs\lib\phantom\phantomjs.exe ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19) at onErrorNT (internal/child_process.js:415:16) at process._tickCallback (internal/process/next_tick.js:63:19) errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn E:\snapshot\fileserver\node_modules\phantom-workers\node_modules\phantomjs\lib\phantom\phantomjs.exe', path: 'E:\snapshot\fileserver\node_modules\phantom-workers\node_modules\phantomjs\lib\phantom\phantomjs.exe', spawnargs: [Array], cmd: 'E:\snapshot\fileserver\node_modules\phantom-workers\node_modules\phantomjs\lib\phantom\phantomjs.exe --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any E:\snapshot\fileserver\node_modules\phantom-html-to-pdf\lib\scripts\serverScript.js' }, { Error: spawn E:\snapshot\fileserver\node_modules\phantom-workers\node_modules\phantomjs\lib\phantom\phantomjs.exe ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19) at onErrorNT (internal/child_process.js:415:16) at process._tickCallback (internal/process/next_tick.js:63:19) errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn E:\snapshot\fileserver\node_modules\phantom-workers\node_modules\phantomjs\lib\phantom\phantomjs.exe', path: 'E:\snapshot\fileserver\node_modules\phantom-workers\node_modules\phantomjs\lib\phantom\phantomjs.exe', spawnargs: [Array], cmd: 'E:\snapshot\fileserver\node_modules\phantom-workers\node_modules\phantomjs\lib\phantom\phantomjs.exe --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any E:\snapshot\fileserver\node_modules\phantom-html-to-pdf\lib\scripts\serverScript.js' } ] }

bjrmatos commented 5 years ago
{ Error: spawn E:\snapshot\fileserver\node_modules\phantom-workers\node_modules\phantomjs\lib\phantom\phantomjs.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)

the ENOENT error means that during execution phantomjs.exe could not be found.. this is common to see in exe builds, and you have to check the docs of the packager you are using (i guess it is pkg) to discover how to include/discover the phantom.exe in the exe you are creating