Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
Fix invalid date output with util.inspect#6504
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
rumkin commented May 1, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
test/parallel/test-util-inspect.js Outdated
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.
Can you use assert.strictEqual() here.
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.
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:
|
lib/util.js Outdated
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.
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
addaleax commented May 1, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
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.