@@ -4104,6 +4104,52 @@ The `node:_http_agent`, `node:_http_client`, `node:_http_common`, `node:_http_in
41044104` node:_http_outgoing ` and ` node:_http_server ` modules are deprecated as they should be considered
41054105an internal nodejs implementation rather than a public facing API, use ` node:http ` instead.
41064106
4107+ ### DEP0200: Closing fs.Dir on garbage collection
4108+
4109+ <!-- YAML
4110+ changes:
4111+ - version: REPLACEME
4112+ pr-url: https://github.com/nodejs/node/pull/59839
4113+ description: Documentation-only deprecation.
4114+ -->
4115+
4116+ Type: Documentation-only
4117+
4118+ Allowing a [ ` fs.Dir ` ] [ ] object to be closed on garbage collection is
4119+ deprecated. In the future, doing so might result in a thrown error that will
4120+ terminate the process.
4121+
4122+ Please ensure that all ` fs.Dir ` objects are explicitly closed using
4123+ ` Dir.prototype.close() ` or ` using ` keyword:
4124+
4125+ ``` mjs
4126+ import { opendir } from ' node:fs/promises' ;
4127+
4128+ {
4129+ await using dir = await opendir (' /async/disposable/directory' );
4130+ } // Closed by dir[Symbol.asyncDispose]()
4131+
4132+ {
4133+ using dir = await opendir (' /sync/disposable/directory' );
4134+ } // Closed by dir[Symbol.dispose]()
4135+
4136+ {
4137+ const dir = await opendir (' /unconditionally/iterated/directory' );
4138+ for await (const entry of dir ) {
4139+ // process an entry
4140+ } // Closed by iterator
4141+ }
4142+
4143+ {
4144+ let dir;
4145+ try {
4146+ dir = await opendir (' /legacy/closeable/directory' );
4147+ } finally {
4148+ await dir? .close ();
4149+ }
4150+ }
4151+ ` ` `
4152+
41074153[DEP0142]: #dep0142-repl_builtinlibs
41084154[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
41094155[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -4159,6 +4205,7 @@ an internal nodejs implementation rather than a public facing API, use `node:htt
41594205[` ecdh .setPublicKey ()` ]: crypto.md#ecdhsetpublickeypublickey-encoding
41604206[` emitter .listenerCount (eventName)` ]: events.md#emitterlistenercounteventname-listener
41614207[` events .listenerCount (emitter, eventName)` ]: events.md#eventslistenercountemitter-eventname
4208+ [` fs .Dir ` ]: fs.md#class-fsdir
41624209[` fs .FileHandle ` ]: fs.md#class-filehandle
41634210[` fs .access ()` ]: fs.md#fsaccesspath-mode-callback
41644211[` fs .appendFile ()` ]: fs.md#fsappendfilepath-data-options-callback
0 commit comments