Open lbattaglioli2000 opened 15 hours ago
A first silly question would be, if the final URL generated by $this->getBuildUrl()
is accessible to the internet. The Lambda function is deployed to AWS and wouldn't be able to access a http://localhost
-URL; but as you're using this in a Laravel Zero app, this shouldn't be an issue.
The "Target closed" error rings a bell. We had a previous issue regarding this in #100. As usual with Puppeteer, it's hard to debug and find a definitive solution.
Some quick checks you could do:
/_pdf-generator
huge?Hahaha, yeah the build URLs are all publicly accessible.
Yessir, I just installed both packages using the latest versions of each!
The HTML on the PDF generator is fairly small. It's pretty much just a couple images on the page, and a snippet of text.
Nope! I'm just trying to take a PNG screenshot of the full web page (as plain old HTML and CSS). Once I have the PNG screenshots, the CLI I'm building compiles the images into a PDF using DomPDF. But I don't think that has anything to do with this, as that should take place after I get the images back from the Lambda function. 🤔
Oh wait, I'm a goofy goober.
I wasn't actually on the latest version. I was on an old version of Browsershot, and composer was pulling in an older version of this package as a result.
However, even after updating I'm still getting this error 😢
Hammerstone\Sidecar\Exceptions\LambdaExecutionException
Lambda Execution Exception for Wnx\SidecarBrowsershot\Functions\BrowsershotFunction: "Command failed: node ./browser.cjs '-f file:///tmp/browsershot.js'
TargetCloseError: Protocol error (Page.navigate): Target closed
at CallbackRegistry.clear (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:146:36)
at CDPSessionImpl._onClosed (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:500:25)
at #onClose (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:292:21)
at Socket.<anonymous> (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/node/PipeTransport.js:24:34)
at Socket.emit (node:events:529:35)
at Pipe.<anonymous> (node:net:350:12) {
cause: ProtocolError
at <instance_members_initializer> (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:49:14)
at new Callback (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:53:16)
at CallbackRegistry.create (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:93:26)
at Connection._rawSend (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:215:26)
at CDPSessionImpl.send (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:465:33)
at navigate (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Frame.js:170:51)
at CDPFrame.goto (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Frame.js:148:17)
at CDPFrame.<anonymous> (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:62:27)
at CDPPage.goto (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:674:39)
at callChrome (/var/task/browser.cjs:277:37)
}
. [TRACE] Error: Command failed: node ./browser.cjs '-f file:///tmp/browsershot.js' TargetCloseError: Protocol error (Page.navigate): Target closed at CallbackRegistry.clear (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:146:36)".
If it helps, here's my composer.json
file too:
{
"name": "deevoted/deevoted-cli",
"description": "DeevotedCLI is a command line utility to leverage the Stepwise API to speed up your development workflow, and make client handoff a breeze.",
"keywords": ["framework", "laravel", "laravel zero", "console", "cli"],
"homepage": "https://stepwise.deevoted.build",
"type": "project",
"license": "MIT",
"support": {
"issues": "https://github.com/DeevotedLLC/DeevotedCLI-v2/issues",
"source": "https://github.com/DeevotedLLC/DeevotedCLI-v2"
},
"authors": [
{
"name": "Luigi Battaglioli",
"email": "luigi@deevoted.com"
}
],
"require": {
"php": "^8.1",
"ext-imagick": "*",
"ext-zip": "*",
"gmostafa/php-graphql-client": "^1.13",
"gmostafa/php-graphql-oqm": "^1.4",
"guzzlehttp/guzzle": "^7.5",
"hammerstone/sidecar": "^0.4.2",
"illuminate/http": "^10.0",
"illuminate/support": "^10.0",
"laminas/laminas-text": "^2.10",
"laravel-zero/phar-updater": "^1.3",
"nunomaduro/laravel-console-menu": "^3.4",
"nunomaduro/termwind": "^1.15",
"pusher/pusher-php-server": "^7.2",
"ratchet/pawl": "^0.4.1",
"react/event-loop": "^1.3",
"spatie/browsershot": "^4.0.0",
"spatie/image": "^2.2",
"spatie/ray": "^1.37",
"spatie/ssh": "^1.8",
"wnx/sidecar-browsershot": "^v2.0.0"
},
"require-dev": {
"laravel-zero/framework": "^10.0",
"laravel/pint": "^1.5",
"mockery/mockery": "^1.5.1",
"pestphp/pest": "^1.22.3"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"GraphQL\\SchemaObject\\": "app/GraphQL/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "stable",
"prefer-stable": true,
"bin": ["builds/deevoted"]
}
I just pulled this package into a Laravel Zero CLI App I'm building, and it seems to be failing to take the screenshots and I'm not sure why.
I can confirm my function is in fact deployed to AWS Lambda.
I've included the error I'm getting when I attempt to run the screenshot. Any help would be appreciated. Not sure if this is a bug, or just skill issue. Happy to provide additional info.
This is the code that is throwing the error: