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

fs: throw fs.access errors in JS #17160

Closed
wants to merge 1 commit into from

Conversation

joyeecheung
Copy link
Member

  • Migrate the type check of path to ERR_INVALID_ARG_TYPE
  • Add template counterparts of ASYNC_CALL, ASYNC_DEST_CALL,
    SYNC_CALL, SYNC_DEST_CALL
  • Migrate the access binding to collect the error context in C++,
    then throw the error in JS
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

fs, errors

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. errors Issues and PRs related to JavaScript errors originated in Node.js core. fs Issues and PRs related to the fs subsystem / file system. labels Nov 20, 2017
@joyeecheung
Copy link
Member Author

The plan is to first migrate the fs errors into JS land, then migrate them to ERR_* if we can find a way to work around compatibility issues.

cc @jasnell

CI: https://ci.nodejs.org/job/node-test-pull-request/11562/

@joyeecheung
Copy link
Member Author

joyeecheung commented Nov 21, 2017

Test failed on Windows because StringFromPath has not been ported over to JS so the extended path prefix was not stripped. Should be fixed now.

CI: https://ci.nodejs.org/job/node-test-pull-request/11590/
CI: https://ci.nodejs.org/job/node-test-pull-request/11591/

@joyeecheung
Copy link
Member Author

CI looks green.

@joyeecheung joyeecheung added the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 22, 2017
@joyeecheung
Copy link
Member Author

This should be semver-major due to the error code changes of "path" type check cc @nodejs/tsc although we already have two TSC approvals


let message = `${ctx.code}: ${ctx.message}, ${ctx.syscall}`;
if (ctx.path) {
const path = stringFromPath(ctx.path);
Copy link
Member Author

Choose a reason for hiding this comment

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

Also @fhinkel does this still LGTY with the stringFromPath changes for fixing Windows?

Copy link
Member

Choose a reason for hiding this comment

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

Still LGTM

src/node_file.cc Outdated
if (!args[1]->IsInt32())
return TYPE_ERROR("mode must be an integer");
Local<Context> context = env->context();
CHECK(args.Length() >= 2 && args[1]->IsInt32());
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Could we change this to two Checks? If one of them fails it's easier to see what fails.

Copy link
Member Author

Choose a reason for hiding this comment

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

@fhinkel Of course!

- Migrate the type check of path to ERR_INVALID_ARG_TYPE
- Add template counterparts of ASYNC_CALL, ASYNC_DEST_CALL,
  SYNC_CALL, SYNC_DEST_CALL
- Port StringFromPath and UVException to JavaScript
- Migrate the access binding to collect the error context in C++,
  then throw the error in JS
@joyeecheung
Copy link
Member Author

Split the checks as suggested by @fhinkel . CI: https://ci.nodejs.org/job/node-test-pull-request/11701/

joyeecheung added a commit that referenced this pull request Nov 25, 2017
- Migrate the type check of path to ERR_INVALID_ARG_TYPE
- Add template counterparts of ASYNC_CALL, ASYNC_DEST_CALL,
  SYNC_CALL, SYNC_DEST_CALL
- Port StringFromPath and UVException to JavaScript
- Migrate the access binding to collect the error context in C++,
  then throw the error in JS

PR-URL: #17160
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@joyeecheung
Copy link
Member Author

Landed in 07d3409, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. errors Issues and PRs related to JavaScript errors originated in Node.js core. fs Issues and PRs related to the fs subsystem / file system. 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.

4 participants