Skip to content
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

lib: align console.table row to the left #50135

Merged

Conversation

MrJithil
Copy link
Contributor

@MrJithil MrJithil commented Oct 11, 2023

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Oct 11, 2023
@Uzlopak
Copy link
Contributor

Uzlopak commented Oct 11, 2023

I am fine with this, but I checked the "spec" and it says nothing regarding the output. Its even worse, LOL

See

https://console.spec.whatwg.org/#table

@MrJithil
Copy link
Contributor Author

I am fine with this, but I checked the "spec" and it says nothing regarding the output. Its even worse, LOL

See

https://console.spec.whatwg.org/#table

Yeah. The WHATWG, is not suppose mention the standards in very detail. They have the links to MDN.

@Uzlopak
Copy link
Contributor

Uzlopak commented Oct 11, 2023

Yes and the mdn does not state that the entries are left aligned but just contains a screenshot.

@meyfa
Copy link
Contributor

meyfa commented Oct 11, 2023

What was the original reason for centering it in Node.js? Is there a git blame?

lib/internal/cli_table.js Outdated Show resolved Hide resolved
@MrJithil MrJithil force-pushed the fix-50117-console-table-alignment branch from 6bbf779 to 2684d81 Compare October 11, 2023 14:38
@marco-ippolito
Copy link
Member

I have the feeling this might break some stuff based on snapshots/benchmarks

Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM this aligns with browser behavior for a primarily browser-compat-reasons API.

@MrJithil MrJithil force-pushed the fix-50117-console-table-alignment branch from 2684d81 to 92ad82b Compare October 25, 2023 13:08
@H4ad H4ad added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Oct 25, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 25, 2023
@nodejs-github-bot
Copy link
Collaborator

Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nodejs-github-bot
Copy link
Collaborator

@H4ad H4ad added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 28, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 28, 2023
@nodejs-github-bot nodejs-github-bot merged commit 14af167 into nodejs:main Oct 28, 2023
56 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 14af167

alexfernandez pushed a commit to alexfernandez/node that referenced this pull request Nov 1, 2023
PR-URL: nodejs#50135
Fixes: nodejs#50117
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@RafaelGSS
Copy link
Member

RafaelGSS commented Nov 8, 2023

It hasn't released yet. Thanks for catching up @marco-ippolito.

Update: Wait, if this is now following the SPEC I wonder if this should be considered semver-major.

@aduh95
Copy link
Contributor

aduh95 commented Nov 8, 2023

The spec doesn't say anything about alignment, technically Node.js was spec-compliant before and after this PR landed. What changes is now Node.js output is closer to what browsers DevTools output.

But anyway, I don't really how this change could break anyone, AFAICT the change is only visual.

@RafaelGSS
Copy link
Member

AFAICT the change is only visual.

Output changes are considered semver-major. Marco tagged it because we've just mentioned it during the collab summit.

@marco-ippolito
Copy link
Member

It hasn't released yet. Thanks for catching up @marco-ippolito.

Update: Wait, if this is now following the SPEC I wonder if this should be considered semver-major.

There is no SPEC, now it just has the same behavior of browser

@aduh95
Copy link
Contributor

aduh95 commented Nov 8, 2023

AFAICT the change is only visual.

Output changes are considered semver-major. Marco tagged it because we've just mentioned it during the collab summit.

I don’t think that’s true, for example changing an error message technically changes the output, yet we don’t consider it semver-major. Also the output of console.table is not observable from JavaScript without watching directly the stdout.

anonrig pushed a commit to anonrig/node that referenced this pull request Nov 9, 2023
PR-URL: nodejs#50553
Refs: nodejs#50135
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
@RafaelGSS
Copy link
Member

I don’t think that’s true, for example changing an error message technically changes the output, yet we don’t consider it semver-major

We do consider error message changes as semver-major or at least, we should.

@aduh95
Copy link
Contributor

aduh95 commented Nov 11, 2023

@RafaelGSS that's not what we say in our documentation:

node/doc/api/errors.md

Lines 285 to 289 in 7c1b1f4

The `error.code` property is a string label that identifies the kind of error.
`error.code` is the most stable way to identify an error. It will only change
between major versions of Node.js. In contrast, `error.message` strings may
change between any versions of Node.js. See [Node.js error codes][] for details
about specific codes.

We also recommend testing only the error code, not the message:
In the case of internal errors, prefer checking only the `code` property:
```js
assert.throws(
() => {
throw new ERR_FS_FILE_TOO_LARGE(`${sizeKiB} Kb`);
},
{ code: 'ERR_FS_FILE_TOO_LARGE' },
// Do not include message: /^File size ([0-9]+ Kb) is greater than 2 GiB$/
);
```

AFAICT, it's always been the case that we have been treating error message update as semver-patch, and recommend users to use the code property to detect errors.

Anyway, to come back to this PR, I really think this is not semver-major, but it's not a hill I'll die on.

@RafaelGSS
Copy link
Member

Oh, I haven't seen or I don't remember these sections, thanks for pointing that out. If we have a doc or a precedence, I won't object to it. @marco-ippolito I will remove the label. In case you strong believe it should be semver-major, ping me.

@RafaelGSS RafaelGSS removed the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 11, 2023
@RafaelGSS
Copy link
Member

RafaelGSS commented Nov 11, 2023

FWIW a resource I found in a quick search #3374.

UPDATE: It was discussed when error.code didn't exist at the time (that is what I understood from this discussion: https://github.com/nodejs/node/pull/4664/files#diff-bbed55d3167db7c16baf3ee2c51acb1b09f7740ab1399ab015226c3df488753aR46). So it's not a fair discussion.

@joyeecheung
Copy link
Member

joyeecheung commented Nov 11, 2023

The reason why we have this entire error.code system (and a former strategic initiative involving years of work assigning these codes) was to prevent having to treat error.message changes as server major. Only errors that are known to have their messages captured in the user land (mostly system errors) can still get the semver major treatment but otherwise error message changes are considered semver patch.

@marco-ippolito
Copy link
Member

I believe @mcollina mentioned output changes in console were semver major.
I'm not sure the comparison it's fair between error.message and console.table,
console.table is widely used for benchmarks and snapshots, in documentation etc..., the output actually matters.
but I'm not gonna insist if it's something documented

@MrJithil MrJithil deleted the fix-50117-console-table-alignment branch November 11, 2023 11:20
@MrJithil MrJithil restored the fix-50117-console-table-alignment branch November 11, 2023 11:20
@MrJithil MrJithil deleted the fix-50117-console-table-alignment branch November 11, 2023 11:20
@MrJithil MrJithil restored the fix-50117-console-table-alignment branch November 11, 2023 11:20
@mcollina
Copy link
Member

output changes can breaking. Maybe let's await backporting to LTS for a bit?

targos pushed a commit that referenced this pull request Nov 11, 2023
PR-URL: #50135
Fixes: #50117
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
targos pushed a commit that referenced this pull request Nov 11, 2023
PR-URL: #50553
Refs: #50135
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
targos pushed a commit that referenced this pull request Nov 14, 2023
PR-URL: #50553
Refs: #50135
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
UlisesGascon pushed a commit that referenced this pull request Dec 11, 2023
PR-URL: #50135
Fixes: #50117
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
UlisesGascon pushed a commit that referenced this pull request Dec 11, 2023
PR-URL: #50553
Refs: #50135
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
@UlisesGascon UlisesGascon mentioned this pull request Dec 12, 2023
@mcollina
Copy link
Member

This should likely not have been backported to v20, it broke our tests.
It also broke Undici tests.

@marco-ippolito
Copy link
Member

This should likely not have been backported to v20, it broke our tests.
It also broke Undici tests.

Can we clearly add to the documentation that console output changes should be semver major?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

console.table text alignment always centered