Type: Runtime

    Allowing a [fs.FileHandle][] object to be closed on garbage collection is deprecated. In the future, doing so might result in a thrown error that will terminate the process.

    Please ensure that all fs.FileHandle objects are explicitly closed using FileHandle.prototype.close() when the fs.FileHandle is no longer needed:

    1. const fsPromises = require('fs').promises;
    2. async function openAndClose() {
    3. let filehandle;
    4. try {
    5. filehandle = await fsPromises.open('thefile.txt', 'r');
    6. } finally {
    7. if (filehandle !== undefined)
    8. await filehandle.close();
    9. }
    10. }