fs: fix realpath{Sync} on resolving pipes/sockets#13028
fs: fix realpath{Sync} on resolving pipes/sockets#13028ebraminio wants to merge 1 commit intonodejs:masterfrom
Conversation
4104b3d to
84cbd7a
Compare
There was a problem hiding this comment.
Use common.isWindows and common.skip() here instead. See here for an example.
There was a problem hiding this comment.
Consider using spawnSync() instead to simplify this a bit and to make future debugging a bit easier.
84cbd7a to
1fa2c30
Compare
|
Both done. |
1fa2c30 to
dbac492
Compare
|
This probably needs more study, both of just not following (this patch) and following to the end and raising [current] or not raising error on following symlinks to pipes/sockets should be discussed, lets close it for now. |
dbac492 to
00f1de7
Compare
|
Updated to follow python result. |
c630b2b to
f39045a
Compare
|
@refack: Hi. Thanks for reviewing my patches. :) Does this need a documentation change also? |
|
Have a look at #13130 (comment) also |
There was a problem hiding this comment.
In adition to sanity, I would consider asserting the value of resolvedPath and the returned value from require('fs').realpathSync('/dev/stdin');
Either in the script literal or console.loging it and adding another assert for stdout.
There was a problem hiding this comment.
Hmm, that resolves to different things on different runs and platforms, that is hard to check I think
There was a problem hiding this comment.
Than check it has a truthy value if (!resolvedPath) process.exit(2)
|
@ebraminio Yes, I would add a note to fs.md#fsrealpathpath-options-callback and Something like *Note*: If `path` resolves to a Socket or a Pipe, the function will return the value of `require('path').resolve(path)`.P.S. this might be a breaking change (a.k.a |
Or is it converted by the notes? |
e65f679 to
035b935
Compare
|
doc is done now, have a look |
doc/api/fs.md
Outdated
There was a problem hiding this comment.
Rebase on master this comment was reverted.
035b935 to
f0146f4
Compare
doc/api/fs.md
Outdated
There was a problem hiding this comment.
BTW is my note actually correct? In that case it's easy to check in the test.
There was a problem hiding this comment.
No I've copy-pasted your comment just in rush, removed the both as I couldn't reach to anything useful for here.
There was a problem hiding this comment.
Show me some input -> output results. I'll phrase something better.
There was a problem hiding this comment.
I am not sure what it should be called, before my patch echo "" | node -e "require('fs').realpath('/dev/stdin', console.log)" was raising error but with my patch now it has a similar result with python, say /proc/12938/fd/pipe:[224961], just on Linux
There was a problem hiding this comment.
*Note*: If `path` resolves to a socket or a pipe, the function will return a system dependent name for that object.e8ed5ba to
eef07fc
Compare
|
So there are a linting error: and a fail on AIX: assert.js:92
throw new AssertionError({
^
AssertionError [ERR_ASSERTION]: 1 === 2
at Object.<anonymous> (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix61-ppc64/test/parallel/test-fs-realpath-pipe.js:33:10)If you don't have a clear idea why this fails on AIX, and since this is not a regression, we could add it to |
e1ae7c5 to
9746ad1
Compare
|
Done. I don't have access to AIX but perhaps it doesn't have the concept of /dev/stdin or that somehow is different there. |
|
cc @nodejs/platform-aix |
|
AIX does not have /dev/stdin. See the second comment in https://unix.stackexchange.com/questions/338667/unix-systems-without-dev-stdin-dev-stdout-and-dev-stderr. I also logged into the community AIX machines and there is no /dev/stdin: So although for redirection behaviour seems to be similar, the files do not actually exist in /dev. Given that the test depends on /dev/stdin, I'd suggest it just be skipped as it is for windows. |
@mhdawson Thanks!
I'm +1 |
9746ad1 to
d4d9120
Compare
Done. |
d4d9120 to
363020c
Compare
|
Pre land CI: https://ci.nodejs.org/job/node-test-commit/10154/ |
|
|
PR-URL: nodejs#13028 Reviewed-By: Refael Ackermann <[email protected]>
|
Landed in b3d1e3d |
PR-URL: #13028 Reviewed-By: Refael Ackermann <[email protected]>
|
The docs here claim that it is adding a new api... should this have been semver minor? |
|
ping |
|
ping @refack |
|
AFAICT this is $ echo "" | node -e "console.log(require('fs').realpathSync('/dev/stdin'))"
Error: ENOENT: no such file or directory, lstat '/proc/180/fd/pipe:[140]'
at Object.fs.lstatSync (fs.js:961:11)
at Object.realpathSync (fs.js:1629:21)so now it returns a sane value: $ echo "" | node -e "console.log(require('fs').realpathSync('/dev/stdin'))"
/proc/577/fd/pipe:[565]Documentation comment could have been "Pipe/Socket resolve support |
|
@refack this doesn't appear broken on v6.x right now |
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
fs
Currently
echo "" | node -e "require('fs').realpath('/dev/stdin', console.log)"and
echo "" | node -e "console.log(require('fs').realpathSync('/dev/stdin'))"are broken due to our logic of realpath and this patch changes node in a way to match python:
echo "" | python -c "import os; print(os.path.realpath('/dev/stdin'))"