From a8367200be84beaf351ec574c1ecfd345bd5dc8e Mon Sep 17 00:00:00 2001 From: lluisemper <58423269+lluisemper@users.noreply.github.com> Date: Tue, 28 Jul 2026 18:06:21 +0200 Subject: [PATCH] doc: add MDN links for explicit resource management in fs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add cross-references to MDN documentation for `using` and `await using` statements in the fs module documentation. Remove TODO comment waiting for MDN documentation availability. Fixes: https://github.com/nodejs/node/issues/59556 PR-URL: https://github.com/nodejs/node/pull/59557 Reviewed-By: René --- doc/api/fs.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 85bfd910b13..dea508929fe 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1183,6 +1183,10 @@ changes: Calls `filehandle.close()` and returns a promise that fulfills when the filehandle is closed. +This method enables the filehandle to be used with [`await using`][], which +will automatically close the file when the scope exits. For more information, +see the [MDN documentation on `using` statements][`using`]. + ### `fsPromises.access(path[, mode])` +See the [MDN documentation on `using` statements][`using`] for more information about +explicit resource management. For detailed information, see the documentation of [`fsPromises.mkdtemp()`][]. @@ -6417,12 +6422,13 @@ removed if it still exists. If the directory cannot be deleted, disposal will throw an error. The object has a `remove()` method which will perform the same task. - +See the [MDN documentation on `using` statements][`using`] for more information about +explicit resource management. For detailed information, see the documentation of [`fs.mkdtemp()`][]. There is no callback-based version of this API because it is designed for use -with the `using` syntax. +with the [`using`][] syntax. The optional `options` argument can be a string specifying an encoding, or an object with an `encoding` property specifying the character encoding to use. @@ -7294,6 +7300,10 @@ changes: Calls `dir.close()` if the directory handle is open, and returns a promise that fulfills when disposal is complete. +This method enables the directory to be used with [`await using`][], which +will automatically close the directory when the scope exits. For more +information, see the [MDN documentation on `using` statements][`using`]. + #### `dir[Symbol.dispose]()`