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.fstat(0) fails on Windows #40006

Closed
targos opened this issue Sep 5, 2021 · 4 comments
Closed

fs.fstat(0) fails on Windows #40006

targos opened this issue Sep 5, 2021 · 4 comments
Labels
fs Issues and PRs related to the fs subsystem / file system. test Issues and PRs related to the tests. windows Issues and PRs related to the Windows platform.

Comments

@targos
Copy link
Member

targos commented Sep 5, 2021

Version

master,v16.8.0

Platform

Microsoft Windows NT 10.0.22000.0 x64 (latest Windows 11 beta)

Subsystem

fs

What steps will reproduce the bug?

Run node test/parallel/test-fs-stat.js

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Test should pass

What do you see instead?

node test/parallel/test-fs-stat.js
node:assert:986
throw newErr;
^

AssertionError [ERR_ASSERTION]: ifError got unwanted exception: EISDIR: illegal operation on a directory, fstat
    at D:\Git\nodejs\node\test\common\index.js:364:12
    at D:\Git\nodejs\node\test\common\index.js:401:15
    at FSReqCallback.oncomplete (node:fs:198:21)
 {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: [Error: EISDIR: illegal operation on a directory, fstat] {
    errno: -4068,
    code: 'EISDIR',
    syscall: 'fstat'
  },
  expected: null,
  operator: 'ifError'
}

Additional information

Fails here:

fs.fstat(-0, common.mustSucceed());

@targos targos added fs Issues and PRs related to the fs subsystem / file system. test Issues and PRs related to the tests. windows Issues and PRs related to the Windows platform. labels Sep 5, 2021
@targos
Copy link
Member Author

targos commented Sep 5, 2021

It can be easily reproduced with the following script:

require('fs').fstatSync(0)

@targos targos changed the title test-fs-stat fails on Windows fs.fstat(0) fails on Windows Sep 5, 2021
@targos
Copy link
Member Author

targos commented Nov 18, 2021

@nodejs/platform-windows This is still an issue on my machine.

StefanStojanovic added a commit to JaneaSystems/libuv that referenced this issue Aug 18, 2022
Calling uv_fs_fstat for stdin, stdout or stderr was resulting in error
on Windows while it was retrieving data on Linux. This change enables
uv_fs_fstat to work on Windows for stdio streams too.

A simple test is also added to check this behavior on all platforms.

It fixes nodejs/node#40006
StefanStojanovic added a commit to JaneaSystems/libuv that referenced this issue Aug 25, 2022
Calling uv_fs_fstat for stdin, stdout or stderr was resulting in error
on Windows while it was retrieving data on Linux. This change enables
uv_fs_fstat to work on Windows for stdio streams too.

A simple test is also added to check this behavior on all platforms.

Refs: nodejs/node#40006
vtjnash added a commit to libuv/libuv that referenced this issue Nov 29, 2022
Calling uv_fs_fstat for file types other then disk type was resulting in
error on Windows while it was retrieving data on Linux. This change
enables getting fstat for pipes and character files on Windows with data
fetched being as reasonable as possible.

A simple test is also added to check this behavior on all platforms. It
uses stdin, stdout and stderr. uv_fs_fstat needs to pass with disk files
pipes and character files (eg. console).

Refs: nodejs/node#40006
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
@StefanStojanovic
Copy link
Contributor

The fix for this landed in libuv libuv/libuv#3811. The next time libuv is updated Node will be fixed as well.

@StefanStojanovic
Copy link
Contributor

After updating libuv to 1.45.0 this is fixed. @targos can you please close the issue? Thanks.

@targos targos closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. test Issues and PRs related to the tests. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

2 participants