Uh oh!
There was an error while loading. Please reload this page.
Fix invalid date output with util.inspect - #6504
Conversation
There was a problem hiding this comment.
Can you use assert.strictEqual() here.
There was a problem hiding this comment.
I'd make this simply:
assert.equal(util.inspect(newDate('')),'Invalid Date');there's no reason to create the second date object.
cjihrig
commented
May 1, 2016
It's not a big deal because whoever lands this can fix it up but:
|
There was a problem hiding this comment.
just a style nit so feel free to ignore...
return ctx.stylize(Number.isNaN(value.getTime()) ?
value.toString() :
Date.prototype.toISOString.call(value),
'date');
... would help eliminate some minor code duplication
jasnell
commented
May 1, 2016
semver-major because of the change in error handling (this eliminates a throw). |
jasnell
commented
May 1, 2016
This restores the pre-v6.0.0 behaviour and probably aligns much more with user expectations than the current behaviour, so I would actually say it’s a bugfix. Otherwise, this means that no object containing an invalid |
cjihrig
commented
May 1, 2016
+1 to bug fix. |
jasnell
commented
May 1, 2016
Works for me! |
rumkin
commented
May 2, 2016
@cjihrig how should I fix branch and comment now in better way? |
cjihrig
commented
May 2, 2016
Github doesn't allow you to target a new branch once a PR is made. However, To change your commit message, you can run |
rumkin
commented
May 3, 2016
@cjihrig Done |
cjihrig
commented
May 3, 2016
LGTM once the comment about using |
Prevent util.inspect of throwing on date object with invalid date value. It changed to output result of toString method call.
jasnell
commented
May 6, 2016
cjihrig
commented
May 6, 2016
LGTM. Thanks for the notification @jasnell |
rumkin
commented
May 7, 2016
evanlucas
commented
May 10, 2016
LGTM. Running CI one more time https://ci.nodejs.org/job/node-test-pull-request/2559/ |
rumkin
commented
May 16, 2016
@cjihrig what's next? Will PR be accepted? |
addaleax
commented
May 16, 2016
@rumkin Thanks for commenting here again, sometimes things like this get a little lost. This LGTM and I’m landing it now. |
Prevent util.inspect of throwing on date object with invalid date value. It changed to output result of toString method call. PR-URL: #6504 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
addaleax
commented
May 16, 2016
Landed in 9c33e0e. Thanks! |
Prevent util.inspect of throwing on date object with invalid date value. It changed to output result of toString method call. PR-URL: #6504 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
MylesBorins
commented
Jun 2, 2016
@nodejs/lts is this something we want to backport? |
addaleax
commented
Jun 2, 2016
@thealphanerd Just fyi, this was prompted by a change that came with the v8 changes in v6.0.0 and should be a no-op in the previous versions. |
Checklist
Description of change
util.inspect produces default string value for invalid date instead of throwing RangeError.