Darshan Sen
aef8abb663
src,fs: remove ToLocalChecked() call from fs::AfterMkdirp()
...
This merges the `IsEmpty()` call and the `ToLocalChecked()` call into a
single `ToLocal()` call.
Signed-off-by: Darshan Sen <darshan.sen@postman.com >
PR-URL: https://github.com/nodejs/node/pull/40386
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-10-20 12:08:10 +00:00
James M Snell
f1d353398e
fs: check closing_ in FileHandle::Close
...
Fix possible flaky failure. Keep uv_fs_close from being called twice
on the same fd.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/39472
Refs: https://github.com/nodejs/node/issues/39464
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2021-07-22 07:09:03 +02:00
James M Snell
e239f5ea36
fs: fix FileHandle::ClosePromise to return persisted Promise
...
Makes the FileHandle::ClosePromise() idempotent, always returning
the same Promise after it has already been successfully called
once. Avoids the possibility of accidental double close events.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/39331
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-07-15 13:43:28 -07:00
Darshan Sen
fa7cdd6fc9
src: use SPrintF in ProcessEmitWarning
...
PR-URL: https://github.com/nodejs/node/pull/38758
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-05-25 07:16:42 -07:00
Juan José Arboleda
c9269a4459
src: remove commented code in node_file.cc
...
The implementation of the `fs.lchmod` method has been moved to JS-land
PR-URL: https://github.com/nodejs/node/pull/38693
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
2021-05-21 12:53:52 -07:00
Zach Bjornson
8886b63cf6
fs: fix error when writing buffers > INT32_MAX
...
This reverts c380ee6785 .
uv_fs_write returns an int, so it is not possible to ask
it to write more than INT32_MAX.
Instead, validate 'length' is an int32 in JS to avoid
the assertion failure.
PR-URL: https://github.com/nodejs/node/pull/38546
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-05-10 15:04:37 -07:00
Darshan Sen
e9ed113052
fs: fix chown abort
...
This syncs the type assertion introduced in the referenced PR in the C++
side. Since chown, lchown, and fchown can accept -1 as a value for uid
and gid, we should also accept signed integers from the JS side.
Fixes: https://github.com/nodejs/node/issues/37995
Refs: https://github.com/nodejs/node/pull/31694
PR-URL: https://github.com/nodejs/node/pull/38004
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-04-02 21:43:23 -07:00
Joyee Cheung
8aa9b772f4
bootstrap: include fs module into the builtin snapshot
...
PR-URL: https://github.com/nodejs/node/pull/36943
Fixes: https://github.com/nodejs/node/issues/35930
Refs: https://github.com/nodejs/node/issues/35711
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-19 19:08:06 +08:00
Joyee Cheung
1b7531cdeb
src: rename binding_data_name to type_name in BindingData
...
Previously, this was a per-class string constant for BindingData
which is used as keys for identifying these objects in the binding
data map. These are just type names of the BindingData.
This patch renames the variable to type_name so that
we can generalize this constant for other BaseObjects and use
it for debugging and logging the types of other BaseObjects.
PR-URL: https://github.com/nodejs/node/pull/37112
Refs: https://github.com/nodejs/node/pull/36943
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2021-02-08 14:00:31 +08:00
Michaël Zasso
b346cd1760
src: avoid implicit type conversions
...
This fixes a bunch of C4244 ('conversion' conversion from 'type1' to
'type2', possible loss of data) MSVC warnings in the code base.
PR-URL: https://github.com/nodejs/node/pull/37149
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-07 17:51:41 -08:00
raisinten
72b678a0b3
fs: allow position parameter to be a BigInt in read and readSync
...
Fixes: https://github.com/nodejs/node/issues/36185
PR-URL: https://github.com/nodejs/node/pull/36190
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-01-13 15:19:50 +01:00
James M Snell
28fe1ef635
src: reduce duplicated boilerplate with new env utility fn
...
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36536
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2021-01-03 12:58:09 -08:00
raisinten
c380ee6785
fs: accept non-32-bit length in writeBuffer
...
Since `length` is `size_t`, it can accept 64-bit integers too.
Refs: https://man7.org/linux/man-pages/man2/write.2.html
Fixes: https://github.com/nodejs/node/issues/36643
PR-URL: https://github.com/nodejs/node/pull/36667
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Yash Ladha <yash@yashladha.in >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
2020-12-30 16:56:18 +00:00
Anna Henningsen
e31a99f01b
src: add missing context scopes
...
Add scopes that ensure that the context associated with the
current Environment is always entered when working with it.
PR-URL: https://github.com/nodejs/node/pull/36413
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-08 06:56:21 -08:00
Yash Ladha
9bf12df344
fs: move method definition from header
...
We are defining the definition of function in the header file itself. It
should be defined in the source file instead of the header file.
PR-URL: https://github.com/nodejs/node/pull/36256
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-11-29 06:03:23 -08:00
Jiawen Geng
6f9cbcf6a6
src: fix v8 api deprecation
...
PR-URL: https://github.com/nodejs/node/pull/35700
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: Shelley Vohr <codebytere@gmail.com >
2020-11-15 16:47:50 +01:00
Yash Ladha
2e4930b36f
src: reduced substring calls
...
Reduced the number of substring calls by 1 as it is a linear time
complexity function. Thus having a larger path might lead to decrease in
performance. Also removed unnecessary string allocation happening in the
block.
PR-URL: https://github.com/nodejs/node/pull/34808
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2020-10-11 22:22:56 +00:00
Yash Ladha
c3d337db5d
src: usage of modernize-use-equals-default
...
Update the destructor and constructor calls to use the default member
function. This will bascially enable the compiler to do better
optimization as the functions as explicitly defined as trivial.
Refs: https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html
PR-URL: https://github.com/nodejs/node/pull/34807
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-08-23 07:22:13 -07:00
sapics
6d5c33525a
src: remove unused variable in node_file.cc
...
PR-URL: https://github.com/nodejs/node/pull/34317
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2020-07-23 07:34:48 -07:00
Anna Henningsen
b58c06d92c
src: add option to track unmanaged file descriptors
...
Add the ability to track “raw” file descriptors, i.e. integers returned
by `fs.open()`, and close them on `Environment` shutdown, to match the
behavior for all other resource types (which are also closed on
shutdown).
PR-URL: https://github.com/nodejs/node/pull/34303
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-07-14 15:07:14 +02:00
Guy Bedford
1237955d41
module: package "imports" field
...
PR-URL: https://github.com/nodejs/node/pull/34117
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
2020-07-09 19:19:35 -07:00
Maël Nison
e202df8e4b
fs: implement lutimes
...
PR-URL: https://github.com/nodejs/node/pull/33399
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2020-06-23 09:14:28 +00:00
Anna Henningsen
8641d94189
worker,fs: make FileHandle transferable
...
Allow passing `FileHandle` instances in the transfer list
of a `.postMessage()` call.
PR-URL: https://github.com/nodejs/node/pull/33772
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-06-14 14:53:40 +02:00
himself65
673f49ac94
src: simplify format in node_file.cc
...
PR-URL: https://github.com/nodejs/node/pull/33660
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-06-03 20:28:27 +08:00
himself65
5007611294
src: use const in constant args.Length()
...
PR-URL: https://github.com/nodejs/node/pull/33555
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
2020-05-25 19:30:26 +02:00
Kirill Shatskiy
8f10bb2da5
esm: share package.json cache between ESM and CJS loaders
...
Refs: https://github.com/nodejs/node/issues/30674
PR-URL: https://github.com/nodejs/node/pull/33229
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-05-24 16:22:31 -07:00
Anna Henningsen
b6b82cba27
src: use enum for refed flag on native immediates
...
Refs: https://github.com/nodejs/node/pull/33320#discussion_r423141443
PR-URL: https://github.com/nodejs/node/pull/33444
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2020-05-21 17:47:56 -07:00
Anna Henningsen
e9f2937507
fs: clean up Dir.read() uv_fs_t data before calling into JS
...
A call into JS can schedule another operation on the same `uv_dir_t`.
In particular, when the handle is closed from the callback for a
directory read operation, there previously was a race condition window:
1. A `dir.read()` operation is submitted to libuv
2. The read operation is finished by libuv, calling `AfterDirRead()`
3. We call into JS
4. JS calls dir.close()
5. libuv posts the close request to a thread in the pool
6. The close request runs, destroying the directory handle
7. `AfterDirRead()` is being exited.
Exiting the `FSReqAfterScope` in step 7 attempts to destroy the original
uv_fs_t` from step 1, which now points to an `uv_dir_t` that has
already been destroyed in step 5.
By forcing the `FSReqAfterScope` to clean up before we call into JS,
we can be sure that no other operations on the same `uv_dir_t` are
submitted concurrently.
This addresses issues observed when running with ASAN/valgrind.
PR-URL: https://github.com/nodejs/node/pull/33274
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2020-05-15 19:36:48 +02:00
Joyee Cheung and Anna Henningsen
86fdaa7455
src: retrieve binding data from the context
...
Instead of passing them through the data bound to function
templates, store references to them in a list embedded inside
the context.
This makes the function templates more context-independent,
and makes it possible to embed binding data in non-main contexts.
Co-authored-by: Anna Henningsen <anna@addaleax.net >
PR-URL: https://github.com/nodejs/node/pull/33139
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2020-05-06 06:44:04 +02:00
Anna Henningsen
e0a7fd7d21
src: use basename(argv0) for --trace-uncaught suggestion
...
Refs: https://github.com/nodejs/node/pull/32797#discussion_r407222290
PR-URL: https://github.com/nodejs/node/pull/32798
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
2020-04-15 02:11:43 +02:00
Tobias Nießen
f4dfbeb12d
src: refactor to avoid goto in node_file.cc
...
PR-URL: https://github.com/nodejs/node/pull/32637
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-04-07 20:29:47 +02:00
Anna Henningsen
f4c2dff4e6
src: move fs state out of Environment
...
Moves state that is specific to the `fs` binding into the
`fs` binding implementation as a cleanup.
PR-URL: https://github.com/nodejs/node/pull/32538
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-04-06 02:06:43 +02:00
Sk Sajidul Kadir
97ef4d76c9
fs: add fs.readv()
...
Fixes: https://github.com/nodejs/node/issues/2298
PR-URL: https://github.com/nodejs/node/pull/32356
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-03-30 10:18:58 +02:00
Anna Henningsen
c011542484
src: prefer OnScopeLeave over shared_ptr<void>
...
They do the same thing, but OnScopeLeave avoids an extra
heap allocation and is more explicit about what it does.
PR-URL: https://github.com/nodejs/node/pull/32247
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Matheus Marchini <mat@mmarchini.me >
2020-03-20 14:20:12 +01:00
cjihrig
8617508d6b
src: fix warn_unused_result compiler warning
...
../src/node_file.cc:386:7: warning: ignoring return value of
function declared with 'warn_unused_result'
attribute [-Wunused-result]
PR-URL: https://github.com/nodejs/node/pull/32241
Refs: https://github.com/nodejs/node/pull/31972
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-03-15 09:51:07 -04:00
Gerhard Stoebich
c145b29987
async_hooks: avoid resource reuse by FileHandle
...
Wrap reused read_wrap in a unique async resource to ensure that
executionAsyncResource() is not ambiguous.
PR-URL: https://github.com/nodejs/node/pull/31972
Refs: https://github.com/nodejs/node/pull/30959
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2020-03-11 19:26:10 +01:00
Ben Noordhuis
da6c7ba2f1
src: remove unused include from node_file.cc
...
PR-URL: https://github.com/nodejs/node/pull/31809
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Denys Otrishko <shishugi@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-03-11 16:57:47 +01:00
James M Snell
0fac393d26
src: improve handling of internal field counting
...
Change suggested by bnoordhuis.
Improve handing of internal field counting by using enums.
Helps protect against future possible breakage if field
indexes are ever changed or added to.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/31960
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-03-02 10:58:36 -08:00
Anna Henningsen
a7c523e26d
src: prefer 3-argument Array::New()
...
This is nicer, because:
1. It reduces overall code size,
2. It’s faster, because `Object::Set()` calls are relatively slow, and
3. It helps avoid invalid `.Check()`/`.FromJust()` calls.
PR-URL: https://github.com/nodejs/node/pull/31775
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
2020-02-15 21:39:32 +01:00
cjihrig
009a9c475b
doc,src,test: assign missing deprecation code
...
PR-URL: https://github.com/nodejs/node/pull/31674
Refs: https://github.com/nodejs/node/pull/28396
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-02-09 11:38:29 -05:00
James M Snell
2d8febceef
fs: deprecate closing FileHandle on garbage collection
...
Closing the FileHandle on garbage collection is a bad practice.
Runtime deprecate and indicate that an error will be thrown in
the future.
PR-URL: https://github.com/nodejs/node/pull/28396
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-02-04 18:29:06 -08:00
bcoe
3f70d77203
fs: set path when mkdir recursive called on file
...
PR-URL: https://github.com/nodejs/node/pull/31607
Fixes: https://github.com/nodejs/node/issues/28015
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
2020-02-03 14:32:20 -08:00
bcoe
13fe56bbbb
fs: return first folder made by mkdir recursive
...
mkdir('/foo/bar', { recursive: true }) and mkdirSync will now return
the path of the first folder created. This matches more closely
mkdirp's behavior, and is useful for setting folder permissions.
PR-URL: https://github.com/nodejs/node/pull/31530
Refs: https://github.com/nodejs/node/issues/31481
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-31 11:57:19 -08:00
bcoe
f2842904c2
fs: bail on permission error in recursive directory creation
...
When creating directories recursively, the logic should bail
immediately on UV_EACCES and bubble the error to the user.
PR-URL: https://github.com/nodejs/node/pull/31505
Fixes: https://github.com/nodejs/node/issues/31481
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-26 22:32:33 -08:00
Anna Henningsen
7864c53629
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 the `FileHandle` return `EBADF`.
Fixes: https://github.com/nodejs/node/issues/31361
PR-URL: https://github.com/nodejs/node/pull/31389
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-18 22:24:54 +01:00
Ben Noordhuis
6623481138
src: fix performance regression in node_file.cc
...
Commits dcb6929 , 4396beb and 8a96d05 turned the O(n) scan in
InternalModuleReadJSON() into an O(4n) scan. Fix the performance
regression by turning that into a linear scan again.
PR-URL: https://github.com/nodejs/node/pull/31343
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-01-15 13:44:29 -08:00
Anna Henningsen
679eb3e7d5
fs: add missing HandleScope to FileHandle.close
...
Fixes: https://github.com/nodejs/node/issues/31202
PR-URL: https://github.com/nodejs/node/pull/31276
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-11 09:51:18 -08:00
Guy Bedford
8a96d05ec7
module: self resolve bug fix and esm ordering
...
PR-URL: https://github.com/nodejs/node/pull/31009
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2019-12-29 11:17:21 -05:00
Anna Henningsen
52a3e35604
src: clean up node_file.h
...
- Move inline functions into an `-inl.h` file
- Move override function definitions into `.cc` files
- Remove `using` statements from header files
- Make data fields of classes private
- Mark classes at the end of hierarchies as `final`
This is also partially being done in an attempt to avoid
a particular internal compiler error, see
https://github.com/nodejs/node/pull/30475#issuecomment-554740850
for details.
PR-URL: https://github.com/nodejs/node/pull/30530
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-11-30 08:51:06 +00:00
Guy Bedford
1eee0b8bf8
module: fix for empty object in InternalModuleReadJSON
...
Fixes: https://github.com/nodejs/node/issues/30245
PR-URL: https://github.com/nodejs/node/pull/30256
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2019-11-08 04:50:02 -08:00