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 <tyler.smalley@elastic.co>
This commit is contained in:
Tyler Smalley 2018-04-02 09:38:56 -07:00 committed by Tyler Smalley
parent f659d5c3f1
commit 476a2fddf0
2 changed files with 13 additions and 1 deletions

View file

@ -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);
});
}

View file

@ -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);
});
}