stefanzweifel / sidecar-browsershot

A Sidecar function to run Browsershot on Lambda.
https://stefanzweifel.dev/posts/2022/06/21/introducing-sidecar-browsershot
MIT License
197 stars 26 forks source link

Error: Navigating frame was detached #128

Closed Francismori7 closed 6 months ago

Francismori7 commented 6 months ago

I'm getting a weird error while trying to generate a PDF:

Lambda Execution Exception for Wnx\SidecarBrowsershot\Functions\BrowsershotFunction: "Command failed: node ./browser.cjs '-f file:///tmp/browsershot.js'
Error: Navigating frame was detached
    at #onFrameDetached (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.js:110:47)
    at /opt/nodejs/node_modules/puppeteer-core/lib/cjs/third_party/mitt/index.js:1:269
    at Array.map (<anonymous>)
    at Object.emit (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/third_party/mitt/index.js:1:252)
    at CDPFrame.emit (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.js:88:22)
    at #removeFramesRecursively (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FrameManager.js:448:15)
    at #onClientDisconnect (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FrameManager.js:114:42)
. [TRACE] Error: Command failed: node ./browser.cjs '-f file:///tmp/browsershot.js' Error: Navigating frame was detached at #onFrameDetached (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.js:110:47)".

Here is the code that was working up until this morning:

        $pdf = BrowsershotLambda::html($html)
            ->showBackground()
            ->format("Letter")
            ->margins(10, 10, 5, 10)
            ->addChromiumArguments([
                "font-render-hinting" => "none",
                "force-color-profile" => "srgb",
            ])
            ->waitUntilNetworkIdle()
            ->pdf();

As a side note, it seems to coincide with another error that popped up this morning regarding available space in /tmp:

Lambda Execution Exception for Wnx\SidecarBrowsershot\Functions\BrowsershotFunction: "ENOSPC: no space left on device, write. [TRACE] Error: ENOSPC: no space left on device, write at Object.writeSync (node:fs:929:3) at Object.writeFileSync (node:fs:2328:26)".
stefanzweifel commented 6 months ago

Someone else reported the same issue yesterday and they could resolve the issue by upgrading the Lambda function to Node 20. https://github.com/stefanzweifel/sidecar-browsershot/issues/127#issuecomment-2084757521

(The latest version of the package already uses Node 20; not sure what version you're using.)

Francismori7 commented 6 months ago

It appears I was still on v1.13.1... wow! I'll try this.

Francismori7 commented 6 months ago

Updating fixed it. Thanks a lot.