question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to log a "request" event while using "response.failaction" settings as "log" instead of throwing an error.

See original GitHub issue

Hapi allows you to choose what to do when response validation fails by setting response.failAction. (ref.: https://hapijs.com/tutorials/validation#failaction)

When we set that option to:

image

the current way that hapi-pino is set to log requests which have the event.channel set to internal doesn’t recognizes that configuration and the log message is ignored.

This is where Hapi check for the response.failAction settings node_modules/@hapi/hapi/lib/toolkit.js image

This is where Hapi creates a log payload using the internal channel node_modules/@hapi/hapi/lib/request.js image

This is where hapi-pino is ignoring the log message: node_modules/hapi-pino/index.js image

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mikeburghcommented, Jun 6, 2020

If anyone else stumbles onto this, the following works to get these errors logged:

server.events.on('request', (event, tags) => {
	if (tags.channel = 'internal') { 
		server.logger.error({req: event.raw.req, err: tags.error, tags:tags.tags}, tags.error.message);
	}
});
0reactions
mcollinacommented, Jun 6, 2020

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid Hapi.js sending 400 error when Validating ...
There are Two Simple Solutions: 1. Use server.ext('onPreResponse' ... As noted by @Clarkie a generic way of catching all errors in your Hapi ......
Read more >
21.1.0 API Reference - hapi.dev
error () when the events are logged via server.log() as well as internally generated server logs. Defaults to no output. request - a...
Read more >
pinojs - Bountysource
When I am starting the server I am seeing the error hapi-pino is already registered . ... Unable to log a "request" event...
Read more >
Find errors & resume jobs with logs in AzCopy (Azure Storage)
When submitting a request to Microsoft Support (or troubleshooting the issue involving any third party), share the redacted version of the ...
Read more >
Handling Joi validation errors in Hapi 17 | by Piotr Karpala
It's an object schema description language and validator for JavaScript objects. It hits all the checkmarks, it's easy to use, readable, fast ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found