Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-21783

zabbix_js timeout behaviour is wrong and undocumented

XMLWordPrintable

    • Sprint 94 (Nov 2022), Sprint 95 (Dec 2022), Sprint 96 (Jan 2023)
    • 0.125

      There are several issues related to timeout functionality observed in zabbix_js:

      Use-case 1

      create file /tmp/script.js so it sleeps for 11 seconds:

      Zabbix.sleep(5000);
      Zabbix.sleep(6000);
      return value;
      

      execute it with timeout 0, result:

      ./bin/zabbix_js -s/tmp/script.js -p 4 -t0
      zabbix_js [401788]: error executing script:
      cannot execute script: RangeError: execution timeout
      

      zabbix_js waited for 10 seconds and then timeout out.

      Use-case 2

      change file contents to sleep for 9 seconds:

      Zabbix.sleep(5000);
      Zabbix.sleep(4000);
      return value;
      

      execute it, result:

      ./bin/zabbix_js -s/tmp/script.js -p 4 -t0
      4
      

      after 9 seconds zabbix_js completed successfully.

      Use-case 3

      set timeout to some large value, result:

      ./bin/zabbix_js -s/tmp/script.js -p 4 -t999999999999
      zabbix_js [402004]: error executing script:
      cannot execute script: RangeError: execution timeout
      

      zabbix_js fails immidately with timeout error.

      Use-case 4

      set timeout to negative value, result:

      ./bin/zabbix_js -s/tmp/script.js -p 4 -t-1
      zabbix_js [401817]: error executing script:
      cannot execute script: RangeError: execution timeout
      

      zabbix_js fails immediately with timeout error.

      Use-case 5

      set timeout to an invalid value, result:

      ./bin/zabbix_js -s/tmp/script.js -p 4 -td
      zabbix_js [401883]: error executing script:
      cannot execute script: RangeError: execution timeout
      

      zabbix_js times out in 10 seconds.

      Summary

      1) There is a default timeout of 10 seconds, but it is not mentioned anywhere in documentation or help message:

      ./bin/zabbix_js -h
      ...
        -t,--timeout timeout         Specify timeout in seconds
      

      Note, that zabbix_get does mention the valid range and default timeout value in both documentation and helper message (zabbix_get in 5.0 does not have timeout option at all, so 6.0 version was used as an example)

        -t --timeout <seconds>           Specify timeout. Valid range: 1-30 seconds (default: 30 seconds).
      

      2) Setting timeout to 0 seconds, does not set the timeout to 0 seconds or disables the timeout.
      The resulting behaviour is identical to setting timeout to an invalid value like 'd'. In both cases - the resulting timeout is set to default 10 seconds.

      3) Setting timeout to negative value is identical to setting timeout to very large value. In both cases script times out immediately with timeout error.

      Current behaviour is wrong and we should add proper timeout validation and update the documentation and helper message to mention the valid interval and default value.

            asestakovs Aleksejs Sestakovs
            arimdjonoks Artjoms Rimdjonoks
            Team B
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: