-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
request: allow bigint values in read() and write() calls
#21994
Comments
But |
Hrmm… then probably only have Hrmm… |
Though I'm not knowledgeable on the internals of it; sorry. |
@ZaneHannanAU So these parameters should be |
The |
Ah. Always get offset and position mixed up.
$ node
> let v = Number.MAX_SAFE_INTEGER
undefined
> v |= 0
-1
> v >>> 0
4294967295
> |
Not sure if that's only for fs.promises or fs.(read|write) tho |
AFAICT See how it's passed to the C++ layer: node/lib/internal/fs/promises.js Lines 219 to 223 in afc5636
Then in C++ the number is read as a 64 bit value: Lines 1627 to 1628 in afc5636
|
We can probably easily extend the API to support bigints up to To go beyond that, we would need libuv to somehow support bigger offsets. |
/cc @nodejs/fs |
Ah; I see now. Basically cast the Other than that you could run a check that If it's that simple then even I could write up a PR. I mostly just needed to know it I guess. Yeah; if libuv supported bigger offsets it'd help. Thank you very much! |
I think it would be better to handle this separately from regular numbers.
Feel free to create a PR and mention me there :) |
... trying to figure out if this'll work... CHECK(args[4]->IsBigInt());
const int64_t pos = args[4].As<Integer>()->Value(); looking at the v8 documentation I don't believe it will but I have no clue. Currently running |
@ZaneHannanAU I believe what you need is |
Thank you! |
... getting errors ../src/node_file.cc: In function ‘void node::fs::FTruncate(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/node_file.cc:1047:66: error: expected primary-expression before ‘)’ token
const int64_t len = args[1].As<v8::BigInt>()->Uint64Value(true*);
^
../src/node_file.cc: In function ‘void node::fs::WriteBuffer(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/node_file.cc:1433:66: error: expected primary-expression before ‘)’ token
const int64_t pos = args[4].As<v8::BigInt>()->Uint64Value(true*);
^
../src/node_file.cc: In function ‘void node::fs::WriteBuffers(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/node_file.cc:1474:60: error: expected primary-expression before ‘)’ token
int64_t pos = args[2].As<v8::BigInt>()->Uint64Value(true*);
^
../src/node_file.cc: In function ‘void node::fs::WriteString(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/node_file.cc:1518:66: error: expected primary-expression before ‘)’ token
const int64_t pos = args[2].As<v8::BigInt>()->Uint64Value(true*);
^
../src/node_file.cc: In function ‘void node::fs::Read(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/node_file.cc:1632:66: error: expected primary-expression before ‘)’ token
const int64_t pos = args[4].As<v8::BigInt>()->Uint64Value(true*); |
... I'm not sure if it's needed but I guess it might work without it? |
went without and instantly crashing $ ./node
> ./node[24219]: ../src/node_file.cc:1631:void node::fs::Read(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `args[4]->IsBigInt()' failed.
1: 0x8b9220 node::Abort() [./node]
2: 0x8b92f5 [./node]
3: 0x8fbb12 [./node]
4: 0xb5d809 [./node]
5: 0xb5e6a4 v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [./node]
6: 0x1a36122dc01d
Aborted (core dumped)
$ |
... guessing I'll need to check everything huh |
okay uh I can't figure out where it's from... see @ZaneHannanAU/node I guess. |
Testing in #22038 but needing help. Thank you. |
Currently working on an application that is likely to read & write from values greater than the 32-bit (technically 32 bit signed int) limit in
fs.(read|write)
andfs.promises.(read|write)
. Wanted to request that these functions be able to accept bigint values for reading/writing files >= 4GiB.Other than that; I'd request the allowing of
bigint
values in egutimes()
,lchmod()
,flags
,truncate()
,mode
,interval
(onwatchFile
),highWaterMark
(mostly just for consistency) and so on. It'd be a massive patch though; plus would likely make some parts incompatible (eg constants that are not pulling fromfs.constants
orprocess.binding('fs').constants
).Of course they shouldn't be using them but... people are human.
The text was updated successfully, but these errors were encountered: