fs: unset FileHandle fd after close
- Do not set the fd as a property on the native object.
- Use the already-existent
GetFD()
method to pass the fd from C++ to JS. - Cache the fd in JS to avoid repeated accesses to the C++ getter.
- Set the fd to
-1
after close, thus reliably making subsequent calls using theFileHandle
returnEBADF
.
Fixes: https://github.com/nodejs/node/issues/31361
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines