From 71343ea507e4202dc9d26ff06bf717f8fcc32b79 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 20 Jul 2021 08:24:30 -0700 Subject: [PATCH] fs: check closing_ in FileHandle::Close Fix possible flaky failure. Keep uv_fs_close from being called twice on the same fd. Refs: https://github.com/nodejs/node/issues/39464 Signed-off-by: James M Snell --- src/node_file.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_file.cc b/src/node_file.cc index 906109e121ae82..e14532d276ee80 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -237,7 +237,7 @@ BaseObjectPtr FileHandle::TransferData::Deserialize( // JS during GC. If closing the fd fails at this point, a fatal exception // will crash the process immediately. inline void FileHandle::Close() { - if (closed_) return; + if (closed_ || closing_) return; uv_fs_t req; int ret = uv_fs_close(env()->event_loop(), &req, fd_, nullptr); uv_fs_req_cleanup(&req);