[ZBX-20765] Empty PDF file is generated by Scheduled Reports Created: 2022 Mar 18  Updated: 2024 Sep 19  Resolved: 2024 Mar 01

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F), Server (S)
Affects Version/s: 6.0.6
Fix Version/s: 6.0.28rc1, 6.4.13rc1, 7.0.0beta1, 7.0 (plan)

Type: Problem report Priority: Major
Reporter: Takashi Yoshihara Assignee: Andrejs Verza
Resolution: Fixed Votes: 11
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Zabbix 6.0.0


Attachments: File 1647238213.Vfd00I1cee7eM480461.zbxsv230     File 1647238502.Vfd00I1d52c2M824369.zbxsv230     PNG File 3.png     PDF File daily_report_230-zbxsv_3_2022-03-14_15-10.pdf     PDF File daily_report_230-zbxsv_8_2022-03-14_15-15.pdf     PNG File error.png     PNG File gauge.png     PNG File geomap-report.png     PNG File image-1.png     PNG File image-2.png     PNG File loader.png     File map.mp4     File pdf_report_creator.go     PNG File pie-chart.png     PNG File screenshot-1.png     File zabbix_server.log.1     File zabbix_server.log.2    
Issue Links:
Causes
causes ZBX-25269 Scheduled reports graph prototypes no... Closed
Duplicate
is duplicated by ZBX-21768 Scheduled reports - blank PDF Closed
is duplicated by ZBX-23549 Scheduled Reports uses guest account ... Closed
Related
related to ZBX-24702 Scheduled reports timeout Closed
Sub-task
Team: Team A
Sprint: Sprint 91 (Aug 2022), Sprint 92 (Sep 2022), Sprint 93 (Oct 2022), Sprint 94 (Nov 2022), Sprint 95 (Dec 2022), Sprint 96 (Jan 2023), Sprint 97 (Feb 2023), Sprint 98 (Mar 2023), Sprint 99 (Apr 2023), Sprint 100 (May 2023), Sprint 101 (Jun 2023), Sprint 102 (Jul 2023), Sprint 103 (Aug 2023), Sprint 104 (Sep 2023), Sprint 105 (Oct 2023), Sprint 106 (Nov 2023), Sprint candidates, S2401-1, S2401-2
Story Points: 0.5

 Description   

Sometimes an empty PDF is created.
When Scheduled Reports created a PDF every day, sometimes it succeeds and sometimes it fails.
To confirm, I duplicated the settings and created the same report every minute.

Steps to reproduce:

  1. Duplicated the Scheduled Reports settings and changed only the name and start time.
    See screenshots (image-1.png and image-2.png).
  2. Wait until the start time and receive reports.

Result:

  One succeeds, the other fails.
  A. Success pattern
      PDF file is output correctly. See following files.
      ・daily_report_230-zbxsv_3_2022-03-14_15-10.pdf: Generated PDF file
      ・zabbix_server.log.1: debug log
      ・1647238213.Vfd00I1cee7eM480461.zbxsv230: Received email
  B. Failed pattern
      PDF file is empty. See following files.
      ・daily_report_230-zbxsv_8_2022-03-14_15-15.pdf: Generated PDF file
      ・zabbix_server.log.2: debug log
      ・1647238502.Vfd00I1d52c2M824369.zbxsv230: Received email



 Comments   
Comment by Nathan Slusher [ 2022 Jun 23 ]

We are also experiencing this issue. Most of the time reports are sent with correct PDFs but sometimes they are blank.

We have tried increasing the timeout value to the max of 30 seconds in /etc/zabbix/zabbix_web_service.conf but it has not fixed the issue.

Comment by Nathan Slusher [ 2022 Jun 23 ]

I believe this issue is caused by the way the web service is waiting for the page to load.

In the source code for the web service there is this comment in the pdf_report_creator.go file:

 

// This comment is taken from the proof of concept example
//
// waitFor blocks until eventName is received.
// Examples of events you can wait for:
//     init, DOMContentLoaded, firstPaint,
//     firstContentfulPaint, firstImagePaint,
//     firstMeaningfulPaintCandidate,
//     load, networkAlmostIdle, firstMeaningfulPaint, networkIdle
//
// This is not super reliable, I've already found incidental cases where
// networkIdle was sent before load. It's probably smart to see how
// puppeteer implements this exactly.
func waitFor(ctx context.Context, eventNames []string) error {
...

 

The code is currently only listening for the "networkIdle" event but there may be a case where that event fires but the page is not fully loaded yet.

I have modified the code to listen for both the "networkIdle" and "load" events before creating the report to hopefully fix this issue.

I uploaded my modified version of the pdf_report_creator.go file to this ticket. I am not a GO programmer so the implementation may not be best practice.

Comment by Nathan Slusher [ 2022 Jun 27 ]

Unfortunately waiting for both the "networkIdle" and "load" events did not resolve the issue - when the issue happens the PDF is no longer blank but the dashboard widgets were not fully loaded.

The log for that report did indicate that the "networkIdle" event fired before the "load" event:

2022/06/25 00:00:06.230499 received report request from 127.0.0.1:38314
2022/06/25 00:00:06.230907 making chrome headless request with parameters url: https://www.website.com/zabbix.php?action=dashboard.print&dashboardid=68&from=2022-06-24%2000%3A00%3A00&to=2022-06-25%2000%3A00%3A00, width: 1920, height: 572 for report request from 127.0.0.1:38314
2022/06/25 00:00:07.463019 fired networkAlmostIdle event
2022/06/25 00:00:07.463187 fired networkIdle event
2022/06/25 00:00:07.463199 hit expected networkIdle event
2022/06/25 00:00:07.464102 fired init event
2022/06/25 00:00:07.769960 fired load event
2022/06/25 00:00:07.769993 hit expected load event
2022/06/25 00:00:07.770002 hit all expected events
2022/06/25 00:00:07.921801 writing response for report request from 127.0.0.1:38314 

A different implementation will be needed to account for this behavior.

Comment by Frantisek [ 2023 Jan 02 ]

Hello, would it be possible to please move the solution and not just move it six months to the next sprint? I would appreciate if this functionality would be functional. Thank you so much

Comment by dimir [ 2023 Dec 08 ]

Looks like the same issue as described here: ZBX-23634

Currently there is no mechanism in Dashboard widget framework to tell some widget is fully loaded. Basically, the browser opens a specific widget using URL and then takes a screenshot. And there is no way to tell if it is fully loaded or not. Such functionality must be implemented in Dashboard widget framework.

Comment by Vladislavs Sokurenko [ 2023 Dec 08 ]

This is because networkIdle is used, see:
https://pkg.go.dev/github.com/troyk/chromedp#WaitForJS
 
func WaitForNetworkIdle() Action
WaitForNetworkIdle should not be used unless absolutely necessary due to race conditions instead, wait for a known element to become visible or WaitforJS see https://github.com/chromedp/chromedp/issues/431

Should we add WaitVisible functionality ?

Comment by Connor McBrine-Ellis [ 2023 Dec 20 ]

I would like Zabbix to prioritize this one as it means Scheduled Reports are basically useless since you can never be sure if it will generate properly or if the report will be empty.

Comment by Mihails Prihodko [ 2023 Dec 20 ]

mcbrineellis, this task is in progress now.

Comment by Andrejs Verza [ 2024 Jan 26 ]

Available in versions:

Generated at Sun May 18 06:46:36 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.