[logger]: express deprecated req.host: Use req.hostname instead
Related issues
[REQUIRED] Version info
4.9.0 (I realize that this isn't the latest version but I have compared the code and couldn't find anything related to logger)
node:
20
firebase-functions:
Hello, I recently experienced this error in a 2nd gen Node.js 20 firebase function and I wanted to pass it along to you fine folks.
This seems to be an issue with the
logger package.
I found a few problems with this issue:
- I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
- This issue does not seem to follow the issue template. Make sure you provide all the required information.
Hey @jdcoldsmith. Could you give me a code sample that causes this log?
It seems to happen for me whenever I call log within an onRequest firebase function. This is how I import log: const { log } = require('firebase-functions/logger');
Hi @jdcoldsmith. We reviewed our source code and don't see any direct reference to the req.host object.
I'm wondering what object you are passing to the logger module. The logger module will iterate through all keys in an object that is passed while serializing the object, and maybe the req.host is being used within that code.
Ahh ok I think I see what could be happening. Whenever I get an error in my function I am passing the entire express request to the log function of logger (e.g. log('Error', { request })). Is it possible that logger is throwing this warning from that?
Hey @jdcoldsmith. Yeah this is entirely possible since the logger iterates over the entire object to format it correctly before actually logging it. I'd recommend you log only properties you're interested in, like the hostname, any query params, etc. instead of logging the entire request object which may be logging a lot of unnecessary information polluting your logs.
But since this is not an issue with the logger itself, I feel safe to close this issue. Thank you!
Ok that makes sense! Thank you!
I fixed it by running npm update.