V4.0
Upgrade Notes
In most cases, v4 should serve as a drop-in replacement for v2 and v3. However, due to changes in the browser backend, various tweaks related to process handling (e.g., worker counts, and so on) may now have different effects than before.
Significant changes have been made to the API for using the server as a Node.js module. While a compatibility layer has been created to address this, it is recommended to transition to the new API described below. It is worth noting that the compatibility layer may be deprecated at some point in the future.
An important note is that the Export Server now requires Node.js v18.12.0 or a higher version.
Additionally, with the v3 release, we transitioned from HTTP to HTTPS for export.highcharts.com, so all requests sent to our public server now must use the HTTPS protocol.
Changelog
Breaking Changes:
- Reordered the
errorandinfoarguments in the callback of thestartExportfunction. - Renamed the environment variables for a better representation of their roles (refer to all envs in the README's
Environment Variablessection). - Renamed the
HIGHCHARTS_MODULESenvironment variable toHIGHCHARTS_MODULE_SCRIPTS. - Renamed the
HIGHCHARTS_INDICATORSenvironment variables toHIGHCHARTS_INDICATOR_SCRIPTS. - Renamed the
POOL_LISTEN_TO_PROCESS_EXITSenvironment variable toOTHER_LISTEN_TO_PROCESS_EXITS. - Renamed the
customCodesection of the options config to thecustomLogicin order to avoid confusion with the existingcustomCodeproperty within. - Renamed the
scriptsproperty in thehighchartssection of the options config to thecustomScripts. - Renamed the
initPoolfunction toinitExportin the main module. - Renamed the
initfunction toinitPoolin the pool module.
New Features:
- Implemented debug mode, including new environment variables, a config section, 'console' event listener, and npm script for debugging the headful Puppeteer browser.
- Added the
HIGHCHARTS_CACHE_PATHoption available through.envto set a custom directory for the fetched files. - Added a moving average indicator for the exporting success rate ratio.
Enhancements:
- Improved server-related error handling by introducing new centralized error middlewares.
- Improved overall error handling by adding a main try-catch block to correctly capture and log errors occurring throughout the code.
- Introduced two new types of custom errors:
ExportErrorfor functionality-related errors andHttpErrorfor server-related errors. - Introduced a new error logging mechanism with stack tracing using new function called
logWithStack. - Expanded some error logs with request IDs.
- Set headless mode to 'shell' for better performance, utilizing an older yet more efficient headless instance.
- Set the
defaultViewportto null and optimized code to triggersetViewportonly once, reducing performance impact during export. - Removed unnecessary initial page on browser launch using
waitForInitialPageand the--no-startup-windowChrome flag. - Revised Chromium flags sent to the browser, now located in the args array within the config file.
- Optimized code by reducing evaluate function calls to enhance performance and minimize jumping between NodeJS and browser processes.
- Optimized and moved chart creation initialization scripts from the HTML template to a separate module named
highcharts.js. - Optimized the
clearPagefunction to ensure content cleaning is only performed once, during resource release. - Introduced the
hardResetPageoption for resetting the page's content (including Highcharts scripts) each time the page is released to the pool (defaulting tofalse). - Introduced the
browserShellModeoption for controlling the mode in which the browser runs (new or old,shellmode). - Optimized creating and acquiring pages from the pool.
- Optimized adding and releasing additional JS and CSS resources.
- Made corrections for gracefully shutting down resources, including running servers, ongoing intervals, browser instance, created pages, and workers pool.
- Updated
createImageandcreatePDFfunctions with faster execution options includingoptimizeForSpeedandquality. - Set
waitUntilto 'domcontentloaded' forsetContentandgotofunctions to improve performance. - Replaced browser's deprecated
isConnected()with theconnectedproperty. - Added information on all available pool resources.
- Numerous minor improvements for performance and stability.
- Moved the
listenToProcessExitsfrom thepoolto theothersection of the options. - Replaced the temporary benchmark module with a simpler server benchmark for evaluating export time.
- Removed unnecessary separate
body-parserpackage (already implemented in Express v4.16+). - Added parsing of envs based on
zodpackage. - Added unit tests for certain parts of the code.
- Added the
shutdownCleanUpfunction for resource release (ending intervals, closing servers, destroying the pool and browser) on shutdown. It will be called in the process exit handlers. - Added new environment variables (
HIGHCHARTS_ADMIN_TOKEN,SERVER_BENCHMARKING, andOTHER_NODE_ENV) to the.env.samplefile, along with their descriptions in the README. - Added a new section to the server configuration options,
proxy, along with corresponding environment variables. - Added several new functions to the
highcharts-export-servermodule, includinginitPool,logWithStack,setLogLevel,enableFileLogging,manualConfig,printLogo, andprintUsage. - Added a new
initLoggingfunction where thesetLogLevelandenableFileLogginglogic are consolidated into one place. - Added a new utility function,
isObjectEmpty. - Added a new logging level (
5) for benchmarking logs. - Added legacy names of options to the
defaultConfigandmapToNewConfigfunction in order to support the old, PhantomJS-based structure of options. - Added a new process event handler for the
SIGHUPsignal. - Added
mapChartandganttChartconstructors in the exporting UI (#503). - Added the series-on-point module (#532).
- Updates were made to the
config.jsfile. - Updated the
killPoolfunction. - The
uncaughtExceptionhandler now kills the pool, browser, and terminates the process with exit code 1, when enabled. - The browser instance should be correctly closed now when an error occurs during pool creation.
- Corrected error handling and response sending in the
/change_hc_version.jsroute. - Corrected the
handleResourcesfunction. - Corrected samples, test scenarios, and test runners.
- Bumped versions of most packages, with an updating deprecated
Puppeteerfromv21.1.1to latest. - Added missing Highcharts modules to stay up-to-date with the latest updates.
- Added missing JSDoc descriptions.
- Revamped all log messages, error messages, prompt messages, and info for improved clarity of information.
- README has been revised and corrected by incorporating additional information, improving descriptions, adding missing details, including new API information, and expanding with new sections such as
Debugging,Available Endpoints,Examples, and aNote about Deprecated Options. - Updated Wiki pages with a new
Samplessection.
Fixes:
- Fixed
multerrelated error: 'Field value too long'. - Fixed the SSL handshake error (#307).
- Fixed missing background color transparency (#492).
- Fixed missing
foreignObjectelements issue. - Fixed type compatibility issues in the
pairArgumentValuefunction, arising from CLI string arguments. - Fixed the 'httpsProxyAgent is not a constructor' issue with the
https-proxy-agentmodule. - Fixed the issue of being unable to run both HTTP and HTTPS servers simultaneously.
- Fixed the issue with the
multiselecttype of values in prompt functionality triggered by the--createConfigoption. - Fixed the error handling in the
postWorkfunction which resulted in doubled errors. - Fixed the deprecated description of the pool from the
generic-pooltotarnnotation, triggered by thegetPoolInfoandgetPoolInfoJSONfunctions. - Fixed the issue of not gracefully terminating the process when an error occurs and a pool or browser already exists.
- Fixed the 'Could not clear the content of the page... - Target closed' error.
- Made minor corrections to ESLint and Prettier configuration.
- Other minor stability, linting and text corrections have been implemented.