-
Notifications
You must be signed in to change notification settings - Fork 30k
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: adjust truncate mode from r+
to a
#43315
base: main
Are you sure you want to change the base?
Conversation
/cc @nodejs/fs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. These examples are for |
b544846
to
375f0a7
Compare
There are a bunch of seemingly related CI failures on Windows.
node:internal/fs/utils:348
throw err;
^
Error: EPERM: operation not permitted, ftruncate
at Object.ftruncateSync (node:fs:1136:3)
at Object.truncateSync (node:fs:1095:14)
at Object.<anonymous> (C:\workspace\node-test-binary-windows-js-suites\node\test\parallel\test-fs-truncate.js:44:4)
at Module._compile (node:internal/modules/cjs/loader:1129:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1183:10)
at Module.load (node:internal/modules/cjs/loader:1007:32)
at Module._load (node:internal/modules/cjs/loader:848:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
at node:internal/main/run_main_module:23:47 {
errno: -4048,
syscall: 'ftruncate',
code: 'EPERM'
}
Node.js v19.0.0-pre On a first glance, it looks like a bug in underlying layer. Most likely an attempt to allocate a sparse zero-filled range on a filesystem (probably FAT?) that doesn't support that. |
Unfortunately, there are still failures on Windows, this will probably need to wait Node.js 20.0.0 if we are able to fix/workaround the failures. |
This PR changes flags in
fsPromises.truncate(path[, len])
,fs.truncate(path[, len], callback)
, andfs.truncateSync(path[, len])
fromr+
toa
.This change:
EACCES
)Creating file is not what pure
truncate(2)
does, but it is done bytruncate(1)
and kinda makes sense.Alternatively, we can check for
W_OK
and throwENOENT
manually.