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: expose realpath(3) bindings #15776

Merged
merged 1 commit into from Nov 9, 2017
Merged

Conversation

bnoordhuis
Copy link
Member

@bnoordhuis bnoordhuis commented Oct 5, 2017

Make the uv_fs_realpath() binding (which calls the libc realpath()
on UNIX and GetFinalPathNameByHandle() on Windows) available as the
fs.realpath.native() and fs.realpathSync.native() functions.

The binding was already available as process.binding('fs').realpath
but was not exposed or tested - and partly broken as a result.

Fixes: #8715
Refs: #7899
CI: https://ci.nodejs.org/job/node-test-pull-request/10411/

If we don't go down this, ah, path, we should just remove the method from src/node_file.cc.

edit: forgot to mention: no documentation just yet because that would be wasted effort if everyone hates this.

@bnoordhuis bnoordhuis added the semver-minor PRs that contain new features and should be released in the next minor version. label Oct 5, 2017
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. labels Oct 5, 2017
cleanup();
}
setup();
common.refreshTmpDir();
Copy link
Member Author

Choose a reason for hiding this comment

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

It gets somewhat lost in the noise but this is a bug fix: the fs.rmdirSync() logic didn't work because a/ contains more than just a/b. It didn't result in actual failures because the test runner cleans it up afterwards.

@bricss bricss mentioned this pull request Oct 5, 2017
Copy link
Contributor

@trevnorris trevnorris left a comment

Choose a reason for hiding this comment

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

Think this is worth documenting. With this addition I imagine that if there are other native fs functions people want they'll request something similar (though I'm not sure what those would be).

@jasnell
Copy link
Member

jasnell commented Oct 12, 2017

I'm happy with this approach.

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

Lgtm but needs docs

@bnoordhuis
Copy link
Member Author

I wrought documentation, PTAL.

Rebase + new CI: https://ci.nodejs.org/job/node-test-pull-request/11282/

Copy link
Member

@jasnell jasnell 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 docs. Thanks @bnoordhuis

Make the `uv_fs_realpath()` binding (which calls the libc `realpath()`
on UNIX and `GetFinalPathNameByHandle()` on Windows) available as the
`fs.realpath.native()` and `fs.realpathSync.native()` functions.

The binding was already available as `process.binding('fs').realpath`
but was not exposed or tested - and partly broken as a result.

Fixes: nodejs#8715
PR-URL: nodejs#15776
Refs: nodejs#7899
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
@bnoordhuis
Copy link
Member Author

Landed in 74023c0. The one CI failure was a known problematic test on AIX.

evanlucas pushed a commit that referenced this pull request Nov 13, 2017
Make the `uv_fs_realpath()` binding (which calls the libc `realpath()`
on UNIX and `GetFinalPathNameByHandle()` on Windows) available as the
`fs.realpath.native()` and `fs.realpathSync.native()` functions.

The binding was already available as `process.binding('fs').realpath`
but was not exposed or tested - and partly broken as a result.

Fixes: #8715
PR-URL: #15776
Refs: #7899
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
@evanlucas evanlucas mentioned this pull request Nov 13, 2017
evanlucas added a commit that referenced this pull request Nov 13, 2017
Notable changes:

* **crypto**:
  - Support building with both 1.1.0 and 1.0.2 (David Benjamin) #16130
* **fs**:
  - fs.realpathSync.native and fs.realpath.native are now exposed (Ben Noordhuis) #15776
* **process**:
  - expose process.ppid (cjihrig) #16839

PR-URL: #16992
evanlucas added a commit that referenced this pull request Nov 13, 2017
Notable changes:

* **crypto**:
  - Support building with both 1.1.0 and 1.0.2 (David Benjamin) #16130
* **fs**:
  - fs.realpathSync.native and fs.realpath.native are now exposed (Ben Noordhuis) #15776
* **process**:
  - expose process.ppid (cjihrig) #16839

PR-URL: #16992
evanlucas added a commit that referenced this pull request Nov 14, 2017
Notable changes:

* **crypto**:
  - Support building with both 1.1.0 and 1.0.2 (David Benjamin) #16130
* **fs**:
  - fs.realpathSync.native and fs.realpath.native are now exposed (Ben Noordhuis) #15776
* **process**:
  - expose process.ppid (cjihrig) #16839

PR-URL: #16992
evanlucas added a commit that referenced this pull request Nov 14, 2017
Notable changes:

* **crypto**:
  - Support building with both 1.1.0 and 1.0.2 (David Benjamin) #16130
* **fs**:
  - fs.realpathSync.native and fs.realpath.native are now exposed (Ben Noordhuis) #15776
* **process**:
  - expose process.ppid (cjihrig) #16839

PR-URL: #16992
@domenic
Copy link
Contributor

domenic commented Nov 15, 2017

Where are the docs? Ctrl+Fing https://nodejs.org/api/fs.html for "native" turns up nothing.

@addaleax
Copy link
Member

@bnoordhuis ^^^

bnoordhuis added a commit to bnoordhuis/io.js that referenced this pull request Nov 16, 2017
Mea culpa, somehow I managed to drop the documentation commit while
merging the pull request.  This should have been included in commit
74023c0 ("fs: expose realpath(3) bindings") from this month.

PR-URL: nodejs#17059
Refs: nodejs#15776
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@bnoordhuis
Copy link
Member Author

Back-porters, this should land together with the documentation from #17059.

@SimenB
Copy link
Member

SimenB commented Dec 6, 2017

Hiya, this completely breaks Jest with the following trace:

../src/node_file.cc:835:void node::RealPath(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `(args.Length()) >= (2)' failed.
 1: node::Abort() [node]
 2: node::Assert(char const* const (*) [4]) [node]
 3: 0x5595756fed3d [node]
 4: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
 5: 0x5595750292df [node]
 6: 0x55957502982f [node]
 7: 0x2e88c60842fd

Should I create a new issue?

Simple repro can be seen in issue jestjs/jest#5030, but also on jest's own code base.

@SimenB
Copy link
Member

SimenB commented Dec 6, 2017

Completely minimal reproduction is: node -p "process.binding('fs').realpath(process.cwd())". Works on 9.1, aborts on 9.2. Adding 'utf8' as second parameter makes it work

@cjihrig
Copy link
Contributor

cjihrig commented Dec 6, 2017

Is Jest using process.binding() directly? If so, it really shouldn't be.

@SimenB
Copy link
Member

SimenB commented Dec 6, 2017

It is indeed. PR on the way.

EDIT: jestjs/jest#5031

@jasnell
Copy link
Member

jasnell commented Dec 6, 2017

Looks like jest also has graceful-fs in it's dependency tree.

graceful-fs is known to be problematic due to it's insistence on using process.binding()

@SimenB
Copy link
Member

SimenB commented Dec 6, 2017

It only happens on the beta releases of jest, not on the version marked latest. Its usage was added recently to fix case sensitivity on Windows (jestjs/jest#4730). PR with "fix": jestjs/jest#5031.

Would be ideal to use the function added in this PR, but we still have to support older versions of node.

MylesBorins pushed a commit that referenced this pull request Dec 11, 2017
Mea culpa, somehow I managed to drop the documentation commit while
merging the pull request.  This should have been included in commit
74023c0 ("fs: expose realpath(3) bindings") from this month.

PR-URL: #17059
Refs: #15776
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@gibfahn
Copy link
Member

gibfahn commented Jan 15, 2018

Release team were -1 on landing on 6.x, but +1 on reconsidering for the next 8.x minor.

@gibfahn gibfahn added the baking-for-lts PRs that need to wait before landing in a LTS release. label Jan 15, 2018
@MylesBorins
Copy link
Member

Choosing not to land this on 8.x right now as it had earlier broken jest and could cause similar unexpected breakages. Someone should feel open to change labels / open a PR if they feel otherwise

@MylesBorins MylesBorins removed baking-for-lts PRs that need to wait before landing in a LTS release. lts-watch-v8.x labels Aug 17, 2018
@MylesBorins
Copy link
Member

quick ping to ensure no one wants to see this backported

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++. fs Issues and PRs related to the fs subsystem / file system. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet