Oops… there was a problem during the request. - Failed to write cache file

Apache 2.4 on Windows 10 PRO
Matomo version: 4.11.0
MySQL version: 10.6.5-MariaDB
PHP version: 8.1.10

Is this a bug in the templates_actionCommon.twig plugin?

ERROR Piwik\FrontController[2022-09-17 00:53:55 UTC] [d2725] Uncaught exception: C:\www\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&idSite=2&period=range&segment=&widget=&showtitle=1&random=6187, CLI mode: 0]

ERROR Piwik\FrontController[2022-09-17 00:59:56 UTC] [ccc55] Uncaught exception: C:\www\matomo\plugins\CoreHome\templates_dataTableCell.twig(16): An exception has been thrown during the rendering of a template (“Failed to write cache file “C:\www\matomo/tmp/templates_c/3a/4af2187633f05753b74fcaa33ed3wbb5.php”.”). [Query: ?date=2022-08-17,2022-09-15&module=Referrers&action=getKeywords&widget=1&isFooterExpandedInDashboard=0&disableLink=0&filter_limit=50&idSite=1&period=range, CLI mode: 0]

Or am I missing something in the php.ini file?

UPDATE: I since added “Authenticated User” to the Security Group and the Failed to write cache file error is now no more. But on /index.php?module=CoreHome&action=index&date=previous30&period=range&idSite=2#?idSite=2&period=range&date=previous30&category=General_Visitors&subcategory=Live_VisitorLog I am still getting this error:

ERROR Piwik\FrontController[2022-09-17 14:53:29 UTC] [c2a69] Uncaught exception: C:\www\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&idSite=2&period=range&segment=&widget=&showtitle=1&random=9281, CLI mode: 0]

Hi,
Do you have some “exotic” char in your tracking, like accents, Cyrillic chars, etc?
How is configured the database charset?

Database Collation is set to utf8mb4_general_ci

Yes - it is possible that I may have accents in setDocumentTitle. I use:

var _paq = _paq || [];
_paq.push([“setDocumentTitle”,"<%= TitleContentHolder %>"]);

where TitleContentHolder may include French or other “exotic” characters.

To note is that it is the page “Visitors > Visits Log” that produces

Oops… there was a problem during the request. Maybe the server had a temporary issue, or maybe you requested a report with too much data. Please try again. If this error occurs repeatedly please contact your Matomo administrator for assistance.

And if I go to “Visitors > Locations” I get the error too, but after several page refresh I finally see the errors go away.

I am still – occasionally – getting

\CoreHome\templates_dataTableFooter.twig(21): An exception has been thrown during the rendering of a template ("Failed to write cache file

Looking at the Network tab I see that I get 500 Internal Server Errors on these pages with these errors.

@innocraft do you have some clues?

I just got this (hope it helps)

ERROR Piwik\ExceptionHandler[2022-09-20 16:18:09 UTC] [f5c24] Uncaught exception: C:\www\matomo\vendor\twig\twig\src\Cache\FilesystemCache.php(76): Failed to write cache file “C:\www\matomo/tmp/templates_c/8b/8b0854839659e496ee6fc33db6686b6e.php”. [Query: ?date=2022-08-21&module=Referrers&action=getKeywords&widget=1&isFooterExpandedInDashboard=0&disableLink=0&filter_limit=50&idSite=2&period=month, CLI mode: 0]

It looks like PHP is just not having the proper permissions to use C:\www\matomo/tmp to write files to.

Could it be that it has to do with my setup? I have 2 PHP running side by side. One for IIS (php-8.1.10-nts-Win32-vs16-x64) and one for Apache (php-8.1.10-Win32-vs16-x64). They are configured separately and kept apart.

And just got these:

Error in Matomo: The date 'today' is not a correct date range. It should have the following format: 'lastN', 'previousN', 'YYYY-MM-DD,YYYY-MM-DD'.

Error in Matomo: Failed to write cache file "C:\www\matomo/tmp/templates_c/8b/8a0854839659c496ee6fc33db6686b6e.php".

Error in Matomo: The file : can not be opened in write mode.

And I forgot to mention, the error only happens with site ID 2. No errors that I know of with the other sites. Site 1 has much more traffic; 2 has not much at all.

Hi @courtens Matomo may in rare cases display an error such as ‘Oops… there was a problem during the request.’ or ‘Internal Server Error’ or ‘500 error’.

When you have such problem, please follow the following steps to resolve the issue:

  1. The most common solution to the message Oops... there was a problem during the request. is to setup Auto-Archiving in your Matomo by following these two steps:
    a) Enabling the crontab to run the core:archive command and
    b) Disabling “Archive reports when viewed from the browser” in the General Settings.
  2. If the error persists, or you’re getting a white screen/page (sometimes called the ‘White screen of death’), it indicates that there is a problem on the server: check in your web server error log file for an error message.
1 Like

Thank you for that information V.K.

Please find above my errors I am getting. The error is “persisting” :roll_eyes: