"This web site encountered an unexpected error"

I’m attempting to do some visual regression testing on our web site, and I’m using Percy to take snapshots. However, I’m getting inconsistent results from my CircleCI configuration. Sometimes the web site pages render correctly, and sometimes the pages render with ’The web site encountered an unexpected error. Please try again later.’

The most confusing aspect of this problem is that I will encounter the unexpected error message, and then click the “Rerun workflow” button in CircleCI and the web page will render correctly.

I’ve spoken with Percy support, and they’ve told me that Percy is capturing the DOM from several web pages. However, I can’t seem to manually encounter this unexpected error message myself using curl, and when I went to check the apache/php error logs, they are routed to stdout, but when I run the Percy command, I don’t see any error message output in the CircleCI logs.

Does anyone have any suggestions for troubleshooting this, or a way for me to make apache and php write log files instead of stdout?

I’ve found a workaround for the problem: if I execute a silent curl again localhost, all the snapshots work properly.