-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
errors: fix stacktrace of SystemError, add more tests and benchmark #49956
Conversation
Is this a candidate for fast-track? |
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.
lgtm
This comment was marked as outdated.
This comment was marked as outdated.
No, I'm not sure it should land as is since we (at least I) don't fully understand the implications. Ideally folks who wrote the original code or contributed to it could weigh in and say "yes, this was why" |
This comment was marked as outdated.
This comment was marked as outdated.
Just that it does not get overseen because it is a review remark: 'use strict'
const { join } = require('path');
const { cp } = require('fs');
const net = require('net');
const sock = join(__dirname, `${process.pid}.sock`);
const server = net.createServer();
server.listen(sock);
cp(sock, __dirname, (err) => {
console.log(err.stack)
server.close();
}); before (main): aras@aras-Lenovo-Legion-5-17ARH05H:~/workspace/node$ node test.js
SystemError [ERR_FS_CP_NON_DIR_TO_DIR]: Cannot overwrite non-directory with directory: cp returned ENOTDIR (cannot overwrite non-directory /home/aras/workspace/node/51128.sock with directory /home/aras/workspace/node) /home/aras/workspace/node
at new SystemError (node:internal/errors:256:5)
at new NodeError (node:internal/errors:367:7)
at checkPaths (node:internal/fs/cp/cp:98:13)
at async cpFn (node:internal/fs/cp/cp:65:17) after (this PR): aras@aras-Lenovo-Legion-5-17ARH05H:~/workspace/node$ ./node test.js
SystemError [ERR_FS_CP_NON_DIR_TO_DIR]: Cannot overwrite non-directory with directory: cp returned ENOTDIR (cannot overwrite non-directory /home/aras/workspace/node/51188.sock with directory /home/aras/workspace/node) /home/aras/workspace/node
at checkPaths (node:internal/fs/cp/cp:98:13)
at async cpFn (node:internal/fs/cp/cp:65:17) |
|
Actually... in captureLargerStackTrace Line 562 in f05d6d0
you need to change it to ErrorCaptureStackTrace(err, err.constructor); But I wonder if we actually should keep captureLargerStackTrace on the long run. |
I tested it. If I patch it with err.constructor it removes the SystemError frames, but basically stackTraceLimit is broken, and instead of getting 3 frames like in my test, i get all 10 frames. |
If #49990 lands, this PR should fit perfectly. |
This comment was marked as outdated.
This comment was marked as outdated.
Commit Queue failed- Loading data for nodejs/node/pull/49956 ✔ Done loading data for nodejs/node/pull/49956 ----------------------------------- PR info ------------------------------------ Title errors: fix stacktrace of SystemError, add more tests and benchmark (#49956) Author Aras Abbasi (@Uzlopak) Branch Uzlopak:improve-system-error -> nodejs:main Labels errors Commits 1 - errors: fix stacktrace of SystemError Committers 1 - uzlopak PR-URL: https://github.com/nodejs/node/pull/49956 Reviewed-By: Matteo Collina Reviewed-By: Benjamin Gruenbaum Reviewed-By: Stephen Belanger Reviewed-By: James M Snell ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/49956 Reviewed-By: Matteo Collina Reviewed-By: Benjamin Gruenbaum Reviewed-By: Stephen Belanger Reviewed-By: James M Snell -------------------------------------------------------------------------------- ℹ This PR was created on Fri, 29 Sep 2023 15:08:46 GMT ✔ Approvals: 4 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/49956#pullrequestreview-1651669625 ✔ - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/49956#pullrequestreview-1651740602 ✔ - Stephen Belanger (@Qard): https://github.com/nodejs/node/pull/49956#pullrequestreview-1669388744 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/49956#pullrequestreview-1795453904 ✘ Last GitHub CI failed ℹ Last Full PR CI on 2023-12-19T01:35:44Z: https://ci.nodejs.org/job/node-test-pull-request/56378/ - Querying data for job/node-test-pull-request/56378/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/7309376899 |
Landed in c74c514 |
PR-URL: #49956 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #49956 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #49956 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Before I wanted to tackle the performance of SystemError I wanted better test coverage for SystemError.
While I was working on the tests, I realized that the stacktrace for SystemError is wrong. I fixed it accordingly ;). It also has slightly performance gains.
So my proposal is:
Benefit of this separate PR is, that we can see by the changes in the tests, if the behaviour of SystemError got changed.