puzpuzpuz / cls-rtracer

Request Tracer - CLS-based request id generation for Express, Fastify, Koa and Hapi, batteries included
MIT License
311 stars 24 forks source link

fix: Hapi plugin could not echo header for error responses #45

Closed crccheck closed 3 years ago

crccheck commented 3 years ago

Hapi does something weird whenever there's an error and the response becomes a Hapi Boom object instead of a Hapi Response. That causes an annoying issue where there's two different ways to set the response header. This adds some guards and sets the header for the error case.

puzpuzpuz commented 3 years ago

@crccheck thanks for your contribution! The fix is now available in v2.5.1.