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

src: include cwd in chdir error message #21526

Closed
wants to merge 1 commit into from

Conversation

addaleax
Copy link
Member

Include the current working directory in the error
message for a failing process.chdir() since that is
usually information relevant for debugging.

This is semver-major because it moves properties
of the error message object.

Inspired by nodejs/help#1355.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Include the current working directory in the error
message for a failing `process.chdir()` since that is
usually information relevant for debugging.

This is semver-major because it moves properties
of the error message object.

Inspired by nodejs/help#1355.
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jun 25, 2018
@addaleax addaleax added semver-major PRs that contain breaking changes and should be released in the next major version. process Issues and PRs related to the process subsystem. labels Jun 25, 2018
@addaleax
Copy link
Member Author

This needs another @nodejs/tsc review

CI: https://ci.nodejs.org/job/node-test-commit/19543/

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

LGTM if CI comes back OK

@Trott
Copy link
Member

Trott commented Jul 1, 2018

Resume Build for CI: https://ci.nodejs.org/job/node-test-pull-request/15697/

@Trott
Copy link
Member

Trott commented Jul 1, 2018

Resume Build did not work out. Let's try this instead for the only failed platform (Windows): https://ci.nodejs.org/job/node-test-commit-windows-fanned/19064/

EDIT: Green! All good on CI front.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

LGTM with a question about a potential edge case

// be helpful information when debugging a `chdir()` failure.
char buf[CHDIR_BUFSIZE];
size_t cwd_len = sizeof(buf);
uv_cwd(buf, &cwd_len);
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible that uv_cwd here returns something different from the original cwd? (I am thinking about Windows since libuv calls SetCurrentDirectoryW after SetCurrentDirectoryW and SetEnvironmentVariableW might fail even after SetCurrentDirectoryW succeeds)

Copy link
Member Author

Choose a reason for hiding this comment

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

@joyeecheung I guess so? It’s not really clear to me how SetEnvironmentVariableW could fail with a runtime error…

I don’t think we really need to worry about it? It’s going to be pretty rare, I think

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 16, 2018
@addaleax
Copy link
Member Author

Landed in cf37945

@addaleax addaleax closed this Jul 17, 2018
@addaleax addaleax deleted the chdir-source branch July 17, 2018 11:58
addaleax added a commit that referenced this pull request Jul 17, 2018
Include the current working directory in the error
message for a failing `process.chdir()` since that is
usually information relevant for debugging.

This is semver-major because it moves properties
of the error message object.

Inspired by nodejs/help#1355.

PR-URL: #21526
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
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. c++ Issues and PRs that require attention from people who are familiar with C++. process Issues and PRs related to the process subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants