-
Notifications
You must be signed in to change notification settings - Fork 201
-
Notifications
You must be signed in to change notification settings - Fork 201
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
logger crashes on moment.js object ( TypeError: config._d.getTime is not a function ) #907
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
fwiw, i suspect the problem is with firebase-functions/src/logger.ts Line 33 in 4028acc
|
btw a workaround is to simply never try to log a moment object. eg, always call |
Digging into this a bit, I think I see the issue. In removeCircular, we loop through all properties of the object and overwrite ones containing circular references with the string '[circular]'. For moment(), this ends up overwriting Gonna write up a quick fix to make this not break horribly, but in general this code is not well suited for complex objects that contain functions. To anyone else running into this issue or similar ones, I think @carchrae's solution of always calling |
i appreciate not wanting to mess things up for currently deployed applications that rely on the sad part for me, in terms of dev experience, is this blew a bunch of time. the other logging tools i used had no problem with moment - but i suspect they don't even try to handle circular refs. one fix, with some performance cost is to wrap all calls to logger with something that transforms the object with fwiw, there should absolutely be more care taken when logging in production (so many wasted cycles go there), but when debugging something i was just trying to dump state and got the strange error. |
Perhaps tangentially related, the logger doesn't seem to handle plain old @carchrae's suggestion of |
This bug seems to be introduced with v3.14. I used to log moment objects in version |
Hey all, I think this should be fixed after the PR is merged + released. This will go out in 3.15.0 - if you still face this issue after that point, please let me know! |
Related issues
arguably, this is a bug with moment.js - but i'm not certain who should fix :
moment/moment#5011
[REQUIRED] Version info
node: 12 and 14
firebase-functions: 3.14.1
firebase-tools: 9.14.0
firebase-admin: 9.9.0
moment: 2.29.1
[REQUIRED] Test case
[REQUIRED] Steps to reproduce
simply run the test case
[REQUIRED] Expected behavior
logger should allow logging of moment object.
[REQUIRED] Actual behavior
note: this happens locally as well as when deployed
Were you able to successfully deploy your functions?
yes
The text was updated successfully, but these errors were encountered: