-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
DevProd Correctness
-
Correctness 2025-06-17, Correctness 2025-06-30
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Currently, Date.prototype.tojson() contains the following code with a comment:
try {
// If this === Date.prototype or this is a Date instance created from
// Object.create(Date.prototype), then the [[DateValue]] internal slot won't be set and will
// lead to a TypeError. We instead treat it as though the [[DateValue]] internal slot is NaN
// in order to be consistent with the ES5 behavior in MongoDB 3.2 and earlier.
this.getTime();
} catch (e) {
if (e instanceof TypeError &&
e.message.includes("Date.prototype.getTime called on incompatible")) {
return new Date(NaN).tojson();
}
throw e;
}
We should check if this is still relevant and remove when the answer is 'no'.