Hello,
This relates to I.N. v5.0.25-26.
Installed on an Apache, Nginx, MariaDB stack, with Cloudways.
I don’t have full root access, but Cloudways may be willing to make configuration adjustments if necessary.
It is not possible to do any PDF related actions on the application. Viewing invoices, or using the PDF design preview system, all result in a 500 error presented in a little white pop-up.
The System Check in I.N. shows everything ticked.
I have the PHANTOMJS_CLOUD_KEY='a-demo-key-with-low-quota-per-ip-address'
.env setting in place.
Oddly, during the installation setup, the PDF generation test succeeded. However, after putting in all settings, and submitting them, the setup page simply refreshed. A partial (very incomplete) .env file was created. I had to manually add in the missing settings from the .env.example
file.
On the second attempt of the Setup page, the PDF test failed.
The following is the output to the laravel.log file from attempting to view the PDF review in the Template Designer:
[2020-11-25 23:24:34] production.ERROR: The command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/1172840721-0226644001606346673\/index.html","action":"pdf","options":{"args":["--no-sandbox"],"viewport":{"width":800,"height":600,"deviceScaleFactor":1},"displayHeaderFooter":false,"waitUntil":"networkidle0","printBackground":true}}'" failed.
Exit Code: 1(General error)
Working directory: /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/public
Output:
================
Error Output:
================
/home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/spatie/browsershot/bin/browser.js:20
const getOutput = async (page, request) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)
{"userId":1,"exception":"[object] (Symfony\\Component\\Process\\Exception\\ProcessFailedException(code: 0): The command \"PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/spatie/browsershot/src/../bin/browser.js' '{\"url\":\"file:\\/\\/\\/tmp\\/1172840721-0226644001606346673\\/index.html\",\"action\":\"pdf\",\"options\":{\"args\":[\"--no-sandbox\"],\"viewport\":{\"width\":800,\"height\":600,\"deviceScaleFactor\":1},\"displayHeaderFooter\":false,\"waitUntil\":\"networkidle0\",\"printBackground\":true}}'\" failed.
Exit Code: 1(General error)
Working directory: /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/public
Output:
================
Error Output:
================
/home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/spatie/browsershot/bin/browser.js:20
const getOutput = async (page, request) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)
at /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/spatie/browsershot/src/Browsershot.php:752)
[stacktrace]
#0 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/spatie/browsershot/src/Browsershot.php(539): Spatie\\Browsershot\\Browsershot->callBrowser(Array)
#1 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Utils/Traits/Pdf/PdfMaker.php(44): Spatie\\Browsershot\\Browsershot->pdf()
#2 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Jobs/Util/PreviewPdf.php(61): App\\Jobs\\Util\\PreviewPdf->makePdf(NULL, NULL, '<!DOCTYPE html ...')
#3 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\\Jobs\\Util\\PreviewPdf->handle()
#4 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#5 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#6 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#7 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php(596): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#8 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate\\Container\\Container->call(Array)
#9 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}(Object(App\\Jobs\\Util\\PreviewPdf))
#10 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(App\\Jobs\\Util\\PreviewPdf))
#11 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#12 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php(65): Illuminate\\Bus\\Dispatcher->dispatchNow(Object(App\\Jobs\\Util\\PreviewPdf))
#13 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Http/Controllers/PreviewController.php(198): App\\Jobs\\Util\\PreviewPdf::dispatchNow('<!DOCTYPE html ...', Object(App\\Models\\Company))
#14 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Http/Controllers/PreviewController.php(132): App\\Http\\Controllers\\PreviewController->blankEntity()
#15 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\PreviewController->show()
#16 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('show', Array)
#17 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(255): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\PreviewController), 'show')
#18 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(197): Illuminate\\Routing\\Route->runController()
#19 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(691): Illuminate\\Routing\\Route->run()
#20 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#21 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Http/Middleware/Locale.php(35): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\Locale->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Http/Middleware/TokenAuth.php(83): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\TokenAuth->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Http/Middleware/SetDb.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\SetDb->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Http/Middleware/Cors.php(34): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\Cors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Http/Middleware/QueryLogging.php(42): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\QueryLogging->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#33 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#34 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(63): Illuminate\\Routing\\Middleware\\ThrottleRequests->handleRequest(Object(Illuminate\\Http\\Request), Object(Closure), Array)
#35 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure), '300', '1')
#36 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#37 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(693): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#38 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(668): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#39 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(634): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#40 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#41 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#42 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#43 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/app/Http/Middleware/Cors.php(34): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#44 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\Cors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#45 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#46 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#47 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#48 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#49 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#50 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#51 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#52 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#53 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(87): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#54 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#55 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/sentry/sentry-laravel/src/Sentry/Laravel/Tracing/Middleware.php(45): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#56 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Sentry\\Laravel\\Tracing\\Middleware->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#57 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#58 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#59 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#60 /home/436413.cloudwaysapps.com/ywqcfgpmty/public_html/public/index.php(57): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#61 {main}
"}
Nothing shows up in the Apache or Nginx error logs.
The following shows up in the Apache access log:
115.189.95.219 - [25/Nov/2020:23:54:32 +0000] "GET /index.php" 302 0 - 15353 27804 0.063 6291456 47.69% 31.79% "/client/invoice/NUYmnlQXMQJ2yxuaujhRg1qSsojgP4EAxhRmAtaTvijPjwF6kwoyrIYuE8ih6zz9/download"
When I do a VIEW PDF on an invoice (in this case just a draft invoice), it does actually create a PDF. But the PDF contains (rather oddly) a screenshot of the login page of my installation.
So it is able to create PDF files. But obviously it’s very odd that the PDF contains a screenshot of my login page. There is no log output to laravel.log when I do the “View PDF” of an invoice. There is no output in the server errors logs. There is this entry in the Apache access log:
The .env file contains the following (I had to partly create this myself, as mentioned above, so please check I’ve not missed anything):
APP_KEY=base64:REDACTED/f4zlCVywiFdhiMJo0Ag=
APP_URL=https://billing.REDACTED.nz/
APP_ENV=production
APP_DEBUG=true
REQUIRE_HTTPS=true
DB_CONNECTION=db-ninja-01
MULTI_DB_ENABLED=false
DB_TYPE=mysql
DB_HOST1=localhost
DB_DATABASE1=REDACTED
DB_USERNAME1=REDACTED
DB_PASSWORD1=REDACTED
DB_PORT1=3306
DEMO_MODE=false
BROADCAST_DRIVER=log
LOG_CHANNEL=stack
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_HOST=smtp.mailgun.org
MAIL_USERNAME=postmaster@mg.REDACTED.nz
MAIL_FROM_NAME='NAME'
MAIL_FROM_ADDRESS=EMAIL@gmail.com
MAIL_PASSWORD=REDACTED-a83a87a9-ea061e06
NINJA_ENVIRONMENT=selfhost
POSTMARK_API_TOKEN=
GOOGLE_MAPS_API_KEY=
PHANTOMJS_KEY='a-demo-key-with-low-quota-per-ip-address'
PHANTOMJS_SECRET=
COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
SENTRY_LARAVEL_DSN=https://cc7e8e2c678041689e53e409b7dba236@sentry.invoicing.co/5
Note: I turned on Debug to see if this would show me anything useful in the log or GUI of the app. It didn’t.
I would appreciate some assistance in troubleshooting this issue. Also, are there alternative aways to generate PDFs from within I.N. ?
Thank you,
Jonathan