Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UnhandledPromiseRejection warning when logging on an ignored path #81

Merged
merged 1 commit into from
Aug 3, 2019

Conversation

qswitcher
Copy link
Contributor

Description

A few days ago I ran into a bug where logging via request.log would cause unhandled promise rejection warnings on routes with disabled logging. I traced it down to this line. Basically on an ignored route, current is equal to the nullLogger which doesn't have a levels property.

Steps to reproduce

  • Add a request.log([level]) statement within a route handler such that level is a valid log level configured within hapi-pino such as 'info', 'warn', 'error', etc.
  • Disable that route by adding it to ignorePaths
  • Make a request to that route

I've added a unit test which reproduces this bug.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 98.861% when pulling b8549d0 on qswitcher:ignore-path-fix into 79ad1b4 on pinojs:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 98.861% when pulling b8549d0 on qswitcher:ignore-path-fix into 79ad1b4 on pinojs:master.

Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good work!

@mcollina mcollina merged commit 20f1f27 into hapijs:master Aug 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants