Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_file.cc')
-rw-r--r--src/node_file.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index 0547b2d35de..6436de5a67e 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -205,10 +205,21 @@ inline void FileHandle::Close() {
// If the close was successful, we still want to emit a process warning
// to notify that the file descriptor was gc'd. We want to be noisy about
// this because not explicitly closing the FileHandle is a bug.
+
env()->SetUnrefImmediate([detail](Environment* env) {
ProcessEmitWarning(env,
"Closing file descriptor %d on garbage collection",
detail.fd);
+ if (env->filehandle_close_warning()) {
+ env->set_filehandle_close_warning(false);
+ ProcessEmitDeprecationWarning(
+ env,
+ "Closing a FileHandle object on garbage collection is deprecated. "
+ "Please close FileHandle objects explicitly using "
+ "FileHandle.prototype.close(). In the future, an error will be "
+ "thrown if a file descriptor is closed during garbage collection.",
+ "DEP00XX").IsNothing();
+ }
});
}