diff --git a/src/node_file.cc b/src/node_file.cc index 259df8256f2e08..bebb3a87564e3e 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -821,7 +821,7 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo& args) { return; } - std::shared_ptr defer_close(nullptr, [fd, loop] (...) { + auto defer_close = OnScopeLeave([fd, loop]() { uv_fs_t close_req; CHECK_EQ(0, uv_fs_close(loop, &close_req, fd, nullptr)); uv_fs_req_cleanup(&close_req); diff --git a/src/node_native_module.cc b/src/node_native_module.cc index 680c585d0fb3df..1b916d645d8639 100644 --- a/src/node_native_module.cc +++ b/src/node_native_module.cc @@ -202,7 +202,7 @@ MaybeLocal NativeModuleLoader::LoadBuiltinModuleSource(Isolate* isolate, CHECK_GE(req.result, 0); uv_fs_req_cleanup(&req); - std::shared_ptr defer_close(nullptr, [file](...) { + auto defer_close = OnScopeLeave([file]() { uv_fs_t close_req; CHECK_EQ(0, uv_fs_close(nullptr, &close_req, file, nullptr)); uv_fs_req_cleanup(&close_req);