Comments (7)
@stefanzweifel This is a weird issue that happens completely randomly, we have no clue what exactly causes it or how to reproduce it. Because when this timeout happens we try it one more time generating the same PDF and everything works... The last time when timeout happened the only clue we got was that CloudWatch log.
Initially, the timeout was 30 seconds, we tried to increase it to 300 seconds, but it still didn't help. When this timeout happens lambda gets "stuck", no amount of timeout helps.
What we did as a workaround:
- lowered browsershot timeout to 30 seconds. when everything works, usually we get the PDF back < 5 seconds
- added a loop of retries up to 5 times, whenever
LambdaExecutionException
happens
use Hammerstone\Sidecar\Exceptions\LambdaExecutionException;
private int $retry = 0;
public function render(): string
{
try {
return $this->browser
->setHtml($this->html)
->format($this->format)
->margins(...$this->margins)
->pdf();
} catch (LambdaExecutionException $exception) {
if ($this->retry < 4) { // 5 times in total, including the first attempt
$this->retry++;
return $this->render();
}
throw $exception;
}
}
I suspect maybe it is related to the underlying library... The CloudWatch log says the deprecation warning is related to fs.rmdir
, not fs.rmdirSync
which is package is using. Maybe we can try node --trace-deprecation
on the layer. There are some reported and closed issues on the puppeteer repository: https://github.com/puppeteer/puppeteer/issues?q=is%3Aissue+rmdir
I also found reported similar issues related to puppeteer-extra
, but I believe this library is not being used here.
from sidecar-browsershot.
As you might have seen, my attempt (#112) at updating our internal code to no longer use fs.rmdir
was not successful. Have to figure out, what the root issue here is.
In the meantime, I've updated an underlying layer to use the latest puppeteer-core version and updated this package to also use an updated Chromium version: https://github.com/stefanzweifel/sidecar-browsershot/releases/tag/v2.1.0
Can't guarantee that this will solve the issues.
from sidecar-browsershot.
@orkhanahmadov From which version did you upgrade? From v1.13.1? Or from something prior?
In this compare view, you can see that between v1.13.1 to v2.0.0 basically nothing changed, besides the new spatie/browsershot:v4.0
requirement and the change to the config file.
I didn't have yet the time to upgrade my own apps to the latest version, so can't speak from experience. Weird that our test suite in the package, that runs on AWS, is green. 🤔
from sidecar-browsershot.
@stefanzweifel ok, turns out it is not related to v2, I guess.
Recently when the timeout happened again, we noticed a CloudWatch log with the following contents:
Is this useful or related?
from sidecar-browsershot.
Thanks for the update @orkhanahmadov. Seems related to a cleanup bit of code:
Will create a PR with a fix soonish.
from sidecar-browsershot.
@orkhanahmadov Would you able to share some code snippets for this issue. I'm not able to replicate your timeout issue on my machine or in my production apps.
I don't assume you run any JavaScript in your Blade views?
I know this sounds like a not ideal solution, but have you tried increasing the timeout of your function? Does the error still occur?
Maybe this is related to the underlying Puppeteer versions. Will work on upgrading the underlying layer to the latest puppeteer-version.
from sidecar-browsershot.
@orkhanahmadov Thanks! Lowering the timeout makes total sense here. Better fail fast than wait for forever and produce unnecessary cost.
Will do some research. 🤓
from sidecar-browsershot.
Related Issues (20)
- encoding differs HOT 5
- Emoji CDN sometimes return 429 HOT 7
- Invoke Error 429 HOT 3
- file_put_contents(/var/task/vendor/wnx/sidecar-browsershot/src/Functions/../../resources/lambda/NotoColorEmoji.ttf): Failed to open stream: Read-only file system HOT 3
- Loading never stop HOT 1
- file_get_contents(/var/task/vendor/spatie/browsershot/bin/browser.js): Failed to open stream: No such file or directory HOT 2
- Deprecated Node Runtime HOT 5
- Function `browsershot` not found in environment `staging` HOT 1
- Generated pdf contains [object Object] HOT 3
- sidecar-deployment-user is not authorized to perform: lambda:GetLayerVersion in me-south-1 HOT 1
- Font issue HOT 6
- TargetCloseError: Protocol error (Page.printToPDF): Target closed HOT 9
- Corrupted PDF on production, fine on local HOT 11
- Unable to install using Laravel 11 HOT 2
- For some reason Chrome did not write a file at `example.pdf` HOT 1
- Error: Navigating frame was detached at #onFrameDetached HOT 3
- Error: Navigating frame was detached HOT 3
- Times out when creating screenshots HOT 2
- Add sidecar v0.6 to the list of allowed versions (right now it just has 4 and 5). HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sidecar-browsershot.