Open Brittank88 opened 1 year ago
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);
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