-
Notifications
You must be signed in to change notification settings - Fork 212
#1703: fixing logger runtime exceptions #1704
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
base: master
Are you sure you want to change the base?
Conversation
These changes seem to work well. Before I see about getting this reviewed and merged in, would be able to fix the linting problem? Thanks for your contribution @bitekas. |
@CorieW the linter errors are fixed. FYI, here's the pull request to resolve the underlying android publisher problem: node-fetch/node-fetch#1849, they are linked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes logger runtime exceptions by addressing issues with circular reference handling and improving lookup efficiency.
- Refactored circular reference detection to utilize a Set instead of an array for O(1) lookup.
- Updated property iteration logic to better handle errors and inherited properties.
Comments suppressed due to low confidence (2)
src/logger/index.ts:76
- The try-catch block here may obscure underlying serialization errors that could be useful for debugging. Consider logging the error or handling it in a way that preserves useful error context.
try { if (refs.has(obj[k])) { returnObj[k] = "[Circular]"; } else { returnObj[k] = removeCircular(obj[k], refs); } } catch { returnObj[k] = "[Error - cannot serialize]"; }
src/logger/index.ts:85
- [nitpick] The fallback for inherited properties may introduce unexpected serialization output. Consider reviewing whether prototype properties should be serialized or omitted entirely.
else { returnObj[k] = "[Error - defined in the prototype but missing in the object]"; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Description
Fixing the issue #1703.
Googleapis returns a proxy to an object with a missing "size" property due to an outdated node-fetch library, and this causes the logger to throw an exception. This PR fixes that.
Also improved lookup time to O(1), and fixed a potential bug for logging objects such as
{ toJSON: true }
: in the current implementationdebug({toJSON: true});
is throwing an exception. Pretty nasty given the amount of the Internet using this logger, and hard to triage. This is also fixed.Code sample