You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While developing an app using laravel and browsershot, I encountered an error (which many people found too) that I cannot for the life of me generate a PDF file using this package (image works fine, flawless). This error keeps popping up when I try many combinations of options :
Protocol error : IO.Read
Apparently this happened because somehow the puppeteers's launched browser (chrome/chromium) closed prematurely, which makes the data lost before it was handled in the laravel code (I can see on Windows task manager that the chromium process launched, and closed before the error happened).
So then I launched a chrome instance using the debug flag (add this to your chrome shortcut, better if you can use a new profile for this)
--remote-debugging-port=9222
This will not close the chrome instance after generating the page, while still also closes the tab used to generate the PDF.
Edit Jan 16th, 2024
Make sure that the debug windows is the first instance of chrome that you open. If you already have another chrome window opened, close them first, start the debug instance, then open up other profiles. In Windows, this will make the library uses the last opened chrome instance to generate the PDF.
This is only a workaround for developing on windows, for live environment, consider using chrome as a service
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
While developing an app using laravel and browsershot, I encountered an error (which many people found too) that I cannot for the life of me generate a PDF file using this package (image works fine, flawless). This error keeps popping up when I try many combinations of options :
Protocol error : IO.Read
Apparently this happened because somehow the puppeteers's launched browser (chrome/chromium) closed prematurely, which makes the data lost before it was handled in the laravel code (I can see on Windows task manager that the chromium process launched, and closed before the error happened).
My solution
I found that I can set an instance to be used by this package https://spatie.be/docs/browsershot/v4/miscellaneous-options/connection-to-a-remote-chrome-instance
So then I launched a chrome instance using the debug flag (add this to your chrome shortcut, better if you can use a new profile for this)
--remote-debugging-port=9222
This will not close the chrome instance after generating the page, while still also closes the tab used to generate the PDF.
Edit Jan 16th, 2024
Make sure that the debug windows is the first instance of chrome that you open. If you already have another chrome window opened, close them first, start the debug instance, then open up other profiles. In Windows, this will make the library uses the last opened chrome instance to generate the PDF.
This is only a workaround for developing on windows, for live environment, consider using chrome as a service
Beta Was this translation helpful? Give feedback.
All reactions