| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@ChALkeR build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/124/pipeline |
Sorry, something went wrong.
|
/cc @nodejs/tsc this is a bit hacky test, so I would be happy with some extra feedback on that. |
Sorry, something went wrong.
|
I like the idea, a few notes:
This does not apply to errors that are removed (those are the missing implementation ones). We did remove errors and merge them, but the documentation for those error codes need to stay forever. |
Sorry, something went wrong.
There was a problem hiding this comment.
Can you make this an absolute path so that it can be run somewhere other than the project directory?
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed, thanks @joyeecheung!
Sorry, something went wrong.
|
Great idea :-) |
Sorry, something went wrong.
But unused errors were removed multiple times from documentation. E.g.:
Were all those done in strictly before those errors got into some releases? I expect not. |
Sorry, something went wrong.
|
I added a doc sorting/formatting check (see above, I updated the post), this is what it currently prints: doc: ERR_HTTP2_HEADERS_AFTER_RESPOND - is out of order
doc: ERR_STREAM_DESTROYED - is out of order
doc: ERR_TLS_RENEGOTIATION_DISABLED - is out of orderI think it makes sense to sort the error codes in docs, as the current order looks like:
Which is not ideal. Also, this prevents future duplicate errors like what e9358af fixed — we had duplicate entries at some point. |
Sorry, something went wrong.
|
One more check added: all doc entries should have appropriate anchors. doc: ERR_SCRIPT_EXECUTION_TIMEOUT - missing anchor or not properly formatted |
Sorry, something went wrong.
|
Updated with a scan of all doc/api/*.md files, found this: impl: ERR_HTTP2_STREAM_CLOSED - missing implementation, mentioned in doc/api/ |
Sorry, something went wrong.
This restores a broken and erroneously removed error, which was accidentially renamed to ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK (notice the "INTST" vs "INST") in 921fb84 (PR nodejs#16874) and then had documentation and implementation removed under the old name in 6e1c25c (PR nodejs#18857), as it appeared unused. This error code never worked or was documented under the mistyped name ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK, so renaming it back to ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK is a semver-patch fix. Refs: nodejs#21440 Refs: nodejs#21470 Refs: nodejs#16874 Refs: nodejs#18857
This restores a broken and erroneously removed error, which was accidentially renamed to ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK (notice the "INTST" vs "INST") in 921fb84 (PR #16874) and then had documentation and implementation removed under the old name in 6e1c25c (PR #18857), as it appeared unused. This error code never worked or was documented under the mistyped name ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK, so renaming it back to ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK is a semver-patch fix. Refs: #21440 Refs: #21470 Refs: #16874 Refs: #18857 PR-URL: #21493 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This restores a broken and erroneously removed error, which was accidentially renamed to ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK (notice the "INTST" vs "INST") in 921fb84 (PR #16874) and then had documentation and implementation removed under the old name in 6e1c25c (PR #18857), as it appeared unused. This error code never worked or was documented under the mistyped name ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK, so renaming it back to ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK is a semver-patch fix. Refs: #21440 Refs: #21470 Refs: #16874 Refs: #18857 PR-URL: #21493 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
The old error code `ERR_HTTP2_STREAM_CLOSED` was removed in commit 0babd18 (pull request nodejs#17406), and the testcase for http2stream.pushStream was changed accordingly, but the documentation change was overlooked. This commit fixes it and aligns the documentation with the testcase. This is a part of the fixes hinted by nodejs#21470, which includes some tests for error codes usage and documentation and enforces a stricter format. Refs: nodejs#21470 Refs: nodejs#17406 PR-URL: nodejs#21487 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
The old error code `ERR_HTTP2_STREAM_CLOSED` was removed in commit 0babd18 (pull request #17406), and the testcase for http2stream.pushStream was changed accordingly, but the documentation change was overlooked. This commit fixes it and aligns the documentation with the testcase. This is a part of the fixes hinted by #21470, which includes some tests for error codes usage and documentation and enforces a stricter format. Refs: #21470 Refs: #17406 PR-URL: #21487 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
|
All the known issues with error codes were resolved (in other PRs), this should pass now. |
Sorry, something went wrong.
|
@nodejs/testing |
Sorry, something went wrong.
The old error code `ERR_HTTP2_STREAM_CLOSED` was removed in commit 0babd18 (pull request nodejs#17406), and the testcase for http2stream.pushStream was changed accordingly, but the documentation change was overlooked. This commit fixes it and aligns the documentation with the testcase. This is a part of the fixes hinted by nodejs#21470, which includes some tests for error codes usage and documentation and enforces a stricter format. Refs: nodejs#21470 Refs: nodejs#17406 PR-URL: nodejs#21487 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This adds several sanity checks for error codes.
It scans:
* all natives (js sources),
* doc/api/*.md documentation
* src/node_errors.h (errors definition from the C++ side).
There is also a whitelist of manually created errors from JS side,
currently consisting of ERR_HTTP2_ERROR and ERR_UNKNOWN_BUILTIN_MODULE.
Alsom all ERR_NAPI_ codes are whitelisted, as those are created directly
on the cpp side, without declaring them first.
The performed checks:
1. All errors used from JS should be defined in `internal/errors` and
present in its .codes object. Whitelist (mentioned above) applies.
2. All errors instantiated from JS without arguments should support
0-arguments version.
3. All errors mentioned in doc should defined either in JS, C++, or
in the whitelist.
4. All errors mentioned anywhere should be documented.
5. Documentation of error codes should be sorted, have no repeats,
and include exactly one entry for every error code mentioned in
the documentation, formatted as `/\n### (ERR_[A-Z0-9_]+)\n`.
6. All doc entries for error codes should have appropriate anchors.
There is also a --report flag, which prints all the current issues and
exits without asserting, for manual inspection.
Individual fixes for those issues are landed in separate commits.
Refs: nodejs#21421
Refs: nodejs#21440
Refs: nodejs#21483
Refs: nodejs#21484
Refs: nodejs#21485
Refs: nodejs#21487
PR-URL: nodejs#21470
|
Ping everyone again ;-). |
Sorry, something went wrong.
|
|
||
| // Check that we can initialize errors called without args | ||
| for (const name of set.noargs) { | ||
| if (!errors[name]) continue; // Already catched that above |
There was a problem hiding this comment.
catched -> caught
Sorry, something went wrong.
There was a problem hiding this comment.
This is a great test! Just left a few suggestions as I believe this could still be improved and we currently have a few custom eslint rules that test for the order and existence without being fully reliable. Since those rules do not work properly all the time (e.g., they do not detect changed docs right away) it would probably be best to remove those in favor of this test.
Sorry, something went wrong.
| for (const file of fs.readdirSync(docdir)) { | ||
| if (!file.endsWith('.md')) continue; | ||
| let data = fs.readFileSync(path.join(docdir, file), 'utf-8'); | ||
| if (file === 'errors.md') data = data.replace(/## Legacy [\s\S]*/, ''); |
There was a problem hiding this comment.
Should docdata maybe just be read here? That way the file must only be read once instead of twice.
Sorry, something went wrong.
|
|
||
| function addSource(source, type) { | ||
| // eslint-disable-next-line node-core/no-unescaped-regexp-dot | ||
| const re = /(.)?(ERR_[A-Z0-9_]+)(..)?/g; |
There was a problem hiding this comment.
If I understand the regexp correct the last part is there to potentially match a JS error called without arguments. If that's the case, could we just change this to: (\(\))??
Sorry, something went wrong.
| const report = process.argv[2] === '--report'; | ||
| const results = []; | ||
| function check(ok, type, name, reason) { | ||
| const label = `${type}: ${name} - ${reason}`; |
There was a problem hiding this comment.
Since the last three argument combined become the label, wouldn't it be best to pass through the label directly?
Sorry, something went wrong.
| const natives = process.binding('natives'); | ||
|
|
||
| // --report prints only the list of failed checks and does not assert | ||
| const report = process.argv[2] === '--report'; |
There was a problem hiding this comment.
I suggest to change that to always asserting but checking all entries first instead of asserting on the first failure.
That way the failures are obvious from the assertion and the user does not have to run the test with this flag (and it's not that obvious that this flag must be used by just taking a glimpse at this).
Sorry, something went wrong.
The old error code `ERR_HTTP2_STREAM_CLOSED` was removed in commit 0babd18 (pull request nodejs#17406), and the testcase for http2stream.pushStream was changed accordingly, but the documentation change was overlooked. This commit fixes it and aligns the documentation with the testcase. This is a part of the fixes hinted by nodejs#21470, which includes some tests for error codes usage and documentation and enforces a stricter format. Refs: nodejs#21470 Refs: nodejs#17406 PR-URL: nodejs#21487 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
The old error code `ERR_HTTP2_STREAM_CLOSED` was removed in commit 0babd18 (pull request nodejs#17406), and the testcase for http2stream.pushStream was changed accordingly, but the documentation change was overlooked. This commit fixes it and aligns the documentation with the testcase. This is a part of the fixes hinted by nodejs#21470, which includes some tests for error codes usage and documentation and enforces a stricter format. Refs: nodejs#21470 Refs: nodejs#17406 PR-URL: nodejs#21487 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
The old error code `ERR_HTTP2_STREAM_CLOSED` was removed in commit 0babd18 (pull request #17406), and the testcase for http2stream.pushStream was changed accordingly, but the documentation change was overlooked. This commit fixes it and aligns the documentation with the testcase. This is a part of the fixes hinted by #21470, which includes some tests for error codes usage and documentation and enforces a stricter format. Refs: #21470 Refs: #17406 Backport-PR-URL: #22850 PR-URL: #21487 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
|
Closing this due to inactivity. Please reopen if needed. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This adds several sanity checks for error codes, ref: #21440.
An early version of this test was used to find #21440 (and is something I came up after seeing #21421).
It scans:
There is also a whitelist of manually created errors from JS side, currently consisting of ERR_HTTP2_ERROR and ERR_UNKNOWN_BUILTIN_MODULE. That could be improved, I guess.
The performed checks:
Whitelist with two exceptions of manually created errors (listed above) applies.
As in new ERR_SOMETHING(), ref: fs: fsPromises.lchmod throws AssertionError on Ubuntu #21421.
The checks are a bit hacky (and scan the source code as text), but they work and I would prefer keeping it simple as we have a common markup for all those.
There is also a --report flag, which prints all the current issues and exits without asserting, for manual inspection.
Current output on v10.5.0:
I believe that all those are actual problems that need to be fixed.
This test currently fails and is blocked on #21440, i.e. fixing all those errors.
Checklist