-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Bug: [BUG] Inspect Polyfill Does Not Gracefully Handle Invalid Dates #266
Labels
bug
Something isn't working
Comments
Can you provide some code so that I can reproduce your example? Thank you |
This is the most concise reproduction I can think of: import { Logger } from "tslog";
(new Logger()).info({ invalidDate: new Date(NaN) }); |
This is a patch I'm using in the meantime: diff --git a/node_modules/tslog/dist/cjs/runtime/browser/util.inspect.polyfil.js b/node_modules/tslog/dist/cjs/runtime/browser/util.inspect.polyfil.js
index a18d789..8d772eb 100644
--- a/node_modules/tslog/dist/cjs/runtime/browser/util.inspect.polyfil.js
b/node_modules/tslog/dist/cjs/runtime/browser/util.inspect.polyfil.js
@@ -78,7 78,7 @@ function isError(e) {
return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
}
function isDate(d) {
- return isObject(d) && objectToString(d) === "[object Date]";
return isObject(d) && objectToString(d) === "[object Date]" && !isNaN(d.valueOf());
}
function objectToString(o) {
return Object.prototype.toString.call(o); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the Bug
In the case of an invalid date present inside an object that is being logged, the polyfill throws:
To Reproduce
Expected Behaviour
I believe that logging should be able to continue without failing hard on invalid data of any kind; what the browser does is show these sorts of invalid dates in particular as
Invalid Date
- pretty simple.Screenshots
Additional context
N/A
Node.js Version
v18.17.0
OS incl. Version
Windows 10
The text was updated successfully, but these errors were encountered: