No PDF with phantomjs (local or cloud)

Hi

I have setup invoiceninja (5.0.4-9a) recently, but am not able to get PDF working…

I have followed https://invoice-ninja.readthedocs.io/en/latest/configure.html#phantomjs and read some posts here on the forum.

They seem to describe a different problem somehow.

Either with local phantomjs or cloud i get the following error upon PDF creation: 500: Internal Server Error

Any ideas how to find the cause? Am I missing something?

laravel.log:

[2020-06-23 14:10:57] local.INFO: GET - https://invoice.mydomain.abc/client/invoice/5iDQFu1CMZrijx0gbEMsNcodCcMjI7V2UzVs67BqCxTifusC1Dw9Tu3E1ixvFk9J/download: 0 queries - 0.00029706954956055  
[2020-06-23 14:10:57] local.ERROR: The command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/var/www/invoiceninja/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/96539254-0879297001592921457\/index.html","action":"pdf","options":{"args":[],"viewport":{"width":800,"height":600,"deviceScaleFactor":1},"displayHeaderFooter":false,"waitUntil":"networkidle0","printBackground":true}}'" failed.

Exit Code: 1(General error)

Working directory: /var/www/invoiceninja/public

Output:
================


Error Output:
================
/usr/local/lib/node_modules/npm/bin/npm-cli.js:84
      let notifier = require('update-notifier')({pkg})
      ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3
/var/www/invoiceninja/vendor/spatie/browsershot/bin/browser.js:6
const [, , ...args] = process.argv;
      ^

SyntaxError: Unexpected token [
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3
 {"exception":"[object] (Symfony\\Component\\Process\\Exception\\ProcessFailedException(code: 0): The command \"PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/var/www/invoiceninja/vendor/spatie/browsershot/src/../bin/browser.js' '{\"url\":\"file:\\/\\/\\/tmp\\/96539254-0879297001592921457\\/index.html\",\"action\":\"pdf\",\"options\":{\"args\":[],\"viewport\":{\"width\":800,\"height\":600,\"deviceScaleFactor\":1},\"displayHeaderFooter\":false,\"waitUntil\":\"networkidle0\",\"printBackground\":true}}'\" failed.

Exit Code: 1(General error)

Working directory: /var/www/invoiceninja/public

Output:
================


Error Output:
================
/usr/local/lib/node_modules/npm/bin/npm-cli.js:84
      let notifier = require('update-notifier')({pkg})
      ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3
/var/www/invoiceninja/vendor/spatie/browsershot/bin/browser.js:6
const [, , ...args] = process.argv;
      ^

SyntaxError: Unexpected token [
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3
 at /var/www/invoiceninja/vendor/spatie/browsershot/src/Browsershot.php:724)
[stacktrace]
#0 /var/www/invoiceninja/vendor/spatie/browsershot/src/Browsershot.php(532): Spatie\\Browsershot\\Browsershot->callBrowser(Array)
#1 /var/www/invoiceninja/app/Utils/Traits/Pdf/PdfMaker.php(59): Spatie\\Browsershot\\Browsershot->pdf()
#2 /var/www/invoiceninja/app/Jobs/Invoice/CreateInvoicePdf.php(87): App\\Jobs\\Invoice\\CreateInvoicePdf->makePdf(NULL, NULL, '<!DOCTYPE html>...')
#3 [internal function]: App\\Jobs\\Invoice\\CreateInvoicePdf->handle()
#4 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#5 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Container/Util.php(36): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#6 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#7 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#8 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#9 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\\Container\\Container->call(Array)
#10 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}(Object(App\\Jobs\\Invoice\\CreateInvoicePdf))
#11 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(App\\Jobs\\Invoice\\CreateInvoicePdf))
#12 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#13 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php(26): Illuminate\\Bus\\Dispatcher->dispatchNow(Object(App\\Jobs\\Invoice\\CreateInvoicePdf))
#14 /var/www/invoiceninja/app/Services/Invoice/GetInvoicePdf.php(46): App\\Jobs\\Invoice\\CreateInvoicePdf::dispatchNow(Object(App\\Models\\InvoiceInvitation))
#15 /var/www/invoiceninja/app/Services/Invoice/InvoiceService.php(108): App\\Services\\Invoice\\GetInvoicePdf->run()
#16 /var/www/invoiceninja/app/Http/Controllers/InvoiceController.php(773): App\\Services\\Invoice\\InvoiceService->getInvoicePdf(Object(App\\Models\\ClientContact))
#17 [internal function]: App\\Http\\Controllers\\InvoiceController->downloadPdf('5iDQFu1CMZrijx0...')
#18 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#19 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('downloadPdf', Array)
#20 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\InvoiceController), 'downloadPdf')
#21 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()
#22 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\\Routing\\Route->run()
#23 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#24 /var/www/invoiceninja/app/Http/Middleware/SetInviteDb.php(52): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\\Http\\Middleware\\SetInviteDb->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /var/www/invoiceninja/app/Http/Middleware/QueryLogging.php(40): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\\Http\\Middleware\\QueryLogging->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#28 /var/www/invoiceninja/app/Http/Middleware/StartupCheck.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#29 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\\Http\\Middleware\\StartupCheck->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#30 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#31 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#32 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(76): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#33 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#34 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#35 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#36 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#37 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#38 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#40 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#41 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#42 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#43 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#44 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#45 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#46 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#47 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#48 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#49 /var/www/invoiceninja/app/Http/Middleware/Cors.php(35): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#50 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\\Http\\Middleware\\Cors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#51 /var/www/invoiceninja/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#52 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#53 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#54 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#55 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#56 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#57 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#58 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#59 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#60 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#61 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#62 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#63 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#64 /var/www/invoiceninja/public/index.php(57): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#65 {main}
"} 
[2020-06-23 14:10:57] local.INFO: GET - https://invoice.mydomain.abc/client/invoice/5iDQFu1CMZrijx0gbEMsNcodCcMjI7V2UzVs67BqCxTifusC1Dw9Tu3E1ixvFk9J/download_pdf: 53 queries - 0.49885702133179  

Hi There!

You may want to try using the latest version ~ 5.0.9 i have bundled headless chrome in that build (we no longer use phantomjs)

Also the document for V5 is found here.

https://invoiceninja.github.io/

thanks!

i am now on 5.0.9-12, but i am still not getting any pdf however.

from the log, something seems to timeout:

[2020-06-29 08:57:55] local.ERROR: The process "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/var/www/invoiceninja/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/1444700776-0871576001593421015\/index.html","action":"pdf","options":{"args":[],"viewport":{"width":800,"height":600,"deviceScaleFactor":1},"displayHeaderFooter":false,"waitUntil":"networkidle0","printBackground":true}}'" exceeded the timeout of 60 seconds. {"exception":"[object] (Symfony\\Component\\Process\\Exception\\ProcessTimedOutException(code: 0): The process \"PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/var/www/invoiceninja/vendor/spatie/browsershot/src/../bin/browser.js' '{\"url\":\"file:\\/\\/\\/tmp\\/1444700776-0871576001593421015\\/index.html\",\"action\":\"pdf\",\"options\":{\"args\":[],\"viewport\":{\"width\":800,\"height\":600,\"deviceScaleFactor\":1},\"displayHeaderFooter\":false,\"waitUntil\":\"networkidle0\",\"printBackground\":true}}'\" exceeded the timeout of 60 seconds. at /var/www/invoiceninja/vendor/symfony/process/Process.php:1253)

did i maybe miss a step during installation?

What hardware are you running on?

I haven’t seen this issue, so i am unsure what to suggest.

If you are able to edit the code, find the file PdfMaker.php

and change

        return $browser->deviceScaleFactor(1)
            ->showBackground()
            ->deviceScaleFactor(1)
            ->waitUntilNetworkIdle(true)
            ->pdf();

to

        return $browser->deviceScaleFactor(1)
            ->showBackground()
            ->timeout(10000)
            ->deviceScaleFactor(1)
            ->waitUntilNetworkIdle(true)
            ->pdf();

It’s an AMD Ryzen 5 1600, with 16GB of RAM on Ubuntu.

I have set the longer timeout, but with the same error sadly :frowning:

Are there any other logs I could check?

That should be more than enough CPU power.

The only thing remaining could be a network timeout attempting to get some resources (images over network) etc

Can you try setting the method from

waitUntilNetworkIdle(true)

to

waitUntilNetworkIdle(false)

in PdfMaker.

It did not change anything in the behavior…

Are any of these warnings relevant?

Also since i updated to 5.0.9 when I first click on view PDF it looks like this:

Then I use the back navigation and do it again. It will look like this (where it loads indefinitely):

Laravel.log seems to be different however:

[2020-06-29 11:43:44] local.ERROR: Trying to get property 'contact' of non-object {"exception":"[object] (ErrorException(code: 0): Trying to get property 'contact' of non-object at /var/www/invoiceninja/app/Http/Controllers/InvoiceController.php:780)
[stacktrace]
#0 /var/www/invoiceninja/app/Http/Controllers/InvoiceController.php(780): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Trying to get p...', '/var/www/invoic...', 780, Array)
#1 [internal function]: App\\Http\\Controllers\\InvoiceController->downloadPdf('5iDQFu1CMZrijx0...')
#2 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#3 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('downloadPdf', Array)
#4 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\InvoiceController), 'downloadPdf')
#5 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()
#6 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\\Routing\\Route->run()
#7 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#8 /var/www/invoiceninja/app/Http/Middleware/SetInviteDb.php(52): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#9 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\\Http\\Middleware\\SetInviteDb->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#10 /var/www/invoiceninja/app/Http/Middleware/QueryLogging.php(40): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#11 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\\Http\\Middleware\\QueryLogging->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#12 /var/www/invoiceninja/app/Http/Middleware/StartupCheck.php(73): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#13 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\\Http\\Middleware\\StartupCheck->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#14 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#15 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#16 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(76): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#17 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#18 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#19 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#20 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#21 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#22 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#23 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#24 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#28 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#29 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#30 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#31 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#32 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#33 /var/www/invoiceninja/app/Http/Middleware/Cors.php(35): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#34 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\\Http\\Middleware\\Cors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /var/www/invoiceninja/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#37 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#38 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#39 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#40 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#41 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#42 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#43 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#44 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#45 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#46 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#47 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#48 /var/www/invoiceninja/public/index.php(57): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#49 {main}
"} 

The console log warnings are fine.

The laravel error is interesting but i don’t think it would be causing the PDFs to fail. That error refers to the fact that the invoice doesn’t have a valid contact set on the invitation which is wrong. Do you see this error on every invoice, or just one?

One thing to try is to run

npm i

from the command line in the document root to reinstall puppeteer.

There may be an underlying package missing on your system.

if after npm i you see lib XCB missing… you will need to install additional packages

I had some problems with node, that may have caused some errors, but they have been resolved now (i guess), fsevents should not matter on linux afaik

$ npm i
> fibers@5.0.0 install /var/www/invoiceninja/node_modules/fibers
> node build.js || nodejs build.js

make: Entering directory '/var/www/invoiceninja/node_modules/fibers/build'
  CXX(target) Release/obj.target/fibers/src/fibers.o
  CXX(target) Release/obj.target/fibers/src/coroutine.o
  CC(target) Release/obj.target/fibers/src/libcoro/coro.o
  SOLINK_MODULE(target) Release/obj.target/fibers.node
  COPY Release/fibers.node
make: Leaving directory '/var/www/invoiceninja/node_modules/fibers/build'
Installed in `/var/www/invoiceninja/node_modules/fibers/bin/linux-x64-46-glibc/fibers.node`
/var/www/invoiceninja
├── all@0.0.0  extraneous
└── fibers@5.0.0  extraneous

npm WARN optional Skipping failed optional dependency /laravel-mix/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.13
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@2.1.3
npm WARN optional Skipping failed optional dependency /watchpack-chokidar2/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.13
npm WARN optional Skipping failed optional dependency /webpack-dev-server/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.13

laravel.log again:

[2020-06-30 10:21:11] local.ERROR: The command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/var/www/invoiceninja/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/18542893-0804617001593512470\/index.html","action":"pdf","options":{"args":[],"viewport":{"width":800,"height":600,"deviceScaleFactor":1},"displayHeaderFooter":false,"waitUntil":"networkidle0","printBackground":true}}'" failed.

Exit Code: 1(General error)

Working directory: /var/www/invoiceninja/public

Output:
================


Error Output:
================
/var/www/invoiceninja/vendor/spatie/browsershot/bin/browser.js:6
const [, , ...args] = process.argv;
      ^

SyntaxError: Unexpected token [
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

So there seems now to be a problem with browsershot?

Can you ensure that PdfMaker.php has been reverted to the original file now after those changes we made?

Sorry, yes, I already did that :slight_smile:

It could be your version of node conflicting?

Oh, that was totally the case! PDFs are generating now :slight_smile:

I thought I had installed a newer node version, but there was the problem, that I only installed it for my “normal” user and thus root and www-data were on 4.x, ouch.

Anyway, thank you very much!

1 Like