From 476a2fddf0c19cda7af09227f07333a46176b778 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Mon, 2 Apr 2018 09:38:56 -0700 Subject: [PATCH] Prevent deprecation warnings in production (#17457) While in production, we use the `no-warnings` flag to prevent warnings from going to STDERR, and instead capture the warning events using our logger. Some warnings are helpful in debugging and/or identifying problems in production, like UnhandledPromiseRejection. Deprecation warnings are not an immediate problem, but an issue with upgrading to the next version of Node. These warnings will continue to be presented to developers, just not for production users. Signed-off-by: Tyler Smalley --- src/cli_plugin/lib/log_warnings.js | 8 +++++++- src/server/warnings/index.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cli_plugin/lib/log_warnings.js b/src/cli_plugin/lib/log_warnings.js index 35d3bd51bc4b..b92b049a0baa 100644 --- a/src/cli_plugin/lib/log_warnings.js +++ b/src/cli_plugin/lib/log_warnings.js @@ -1,5 +1,11 @@ export default function (settings, logger) { - process.on('warning', (warning) => { + process.on('warning', warning => { + // deprecation warnings do no reflect a current problem for + // the user and therefor should be filtered out. + if (warning.name === 'DeprecationWarning') { + return; + } + logger.error(warning); }); } diff --git a/src/server/warnings/index.js b/src/server/warnings/index.js index 2e2a9348835d..780124280303 100644 --- a/src/server/warnings/index.js +++ b/src/server/warnings/index.js @@ -1,5 +1,11 @@ export default function (kbnServer, server) { process.on('warning', (warning) => { + // deprecation warnings do no reflect a current problem for + // the user and therefor should be filtered out. + if (warning.name === 'DeprecationWarning') { + return; + } + server.log(['warning', 'process'], warning); }); }