8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 13dbbdc commit cc1aacaCopy full SHA for cc1aaca
doc/api/fs.md
@@ -863,7 +863,8 @@ added:
863
864
> Stability: 1 - Experimental
865
866
-An alias for `filehandle.close()`.
+Calls `filehandle.close()` and returns a promise that fulfills when the
867
+filehandle is closed.
868
869
### `fsPromises.access(path[, mode])`
870
@@ -6753,7 +6754,8 @@ added: v24.1.0
6753
6754
6755
6756
-An alias for `dir.close()`.
6757
+Calls `dir.close()` and returns a promise that fulfills when the
6758
+dir is closed.
6759
6760
#### `dir[Symbol.Dispose]()`
6761
@@ -6763,7 +6765,7 @@ added: v24.1.0
6763
6765
6764
6766
6767
-An alias for `dir.closeSync()`.
6768
+Calls `dir.closeSync()` and returns `undefined`.
6769
6770
### Class: `fs.Dirent`
6771
lib/_http_server.js
@@ -581,7 +581,7 @@ Server.prototype.close = function close() {
581
};
582
583
Server.prototype[SymbolAsyncDispose] = assignFunctionName(SymbolAsyncDispose, async function() {
584
- return promisify(this.close).call(this);
+ await promisify(this.close).call(this);
585
});
586
587
Server.prototype.closeAllConnections = function closeAllConnections() {
lib/dgram.js
@@ -802,7 +802,7 @@ Socket.prototype[SymbolAsyncDispose] = async function() {
802
if (!this[kStateSymbol].handle) {
803
return;
804
}
805
- return FunctionPrototypeCall(promisify(this.close), this);
+ await FunctionPrototypeCall(promisify(this.close), this);
806
807
808
lib/https.js
@@ -117,7 +117,7 @@ Server.prototype.close = function close() {
117
118
119
Server.prototype[SymbolAsyncDispose] = async function() {
120
121
122
123
/**
lib/internal/fs/dir.js
@@ -23,7 +23,10 @@ const {
23
} = require('internal/errors');
24
25
const { FSReqCallback } = binding;
26
-const internalUtil = require('internal/util');
+const {
27
+ assignFunctionName,
28
+ promisify,
29
+} = require('internal/util');
30
const {
31
getDirent,
32
getOptions,
@@ -59,9 +62,9 @@ class Dir {
59
62
validateUint32(this.#options.bufferSize, 'options.bufferSize', true);
60
63
61
64
this.#readPromisified = FunctionPrototypeBind(
- internalUtil.promisify(this.#readImpl), this, false);
65
+ promisify(this.#readImpl), this, false);
66
this.#closePromisified = FunctionPrototypeBind(
- internalUtil.promisify(this.close), this);
67
+ promisify(this.close), this);
68
69
70
get path() {
@@ -304,12 +307,16 @@ ObjectDefineProperties(Dir.prototype, {
304
307
[SymbolDispose]: {
305
308
__proto__: null,
306
309
...nonEnumerableDescriptor,
- value: Dir.prototype.closeSync,
310
+ value: assignFunctionName(SymbolDispose, function() {
311
+ this.closeSync();
312
+ }),
313
},
314
[SymbolAsyncDispose]: {
315
316
- value: Dir.prototype.close,
317
+ value: assignFunctionName(SymbolAsyncDispose, function() {
318
+ this.close();
319
320
321
[SymbolAsyncIterator]: {
322
lib/internal/fs/promises.js
@@ -273,7 +273,7 @@ class FileHandle extends EventEmitter {
273
274
275
async [SymbolAsyncDispose]() {
276
- return this.close();
+ await this.close();
277
278
279
lib/internal/http2/core.js
@@ -3340,7 +3340,7 @@ class Http2Server extends NETServer {
3340
3341
3342
3343
- return promisify(super.close).call(this);
+ await promisify(super.close).call(this);
3344
3345
3346
lib/internal/readline/interface.js
@@ -51,7 +51,10 @@ const {
51
validateString,
52
validateUint32,
53
} = require('internal/validators');
54
-const { kEmptyObject } = require('internal/util');
55
56
+ kEmptyObject,
57
58
inspect,
getStringWidth,
@@ -1637,7 +1640,9 @@ class Interface extends InterfaceConstructor {
1637
1640
return this[kLineObjectStream];
1638
1641
1639
1642
-Interface.prototype[SymbolDispose] = Interface.prototype.close;
1643
+Interface.prototype[SymbolDispose] = assignFunctionName(SymbolDispose, function() {
1644
1645
+});
1646
1647
module.exports = {
1648
Interface,
lib/internal/streams/readable.js
@@ -369,13 +369,13 @@ Readable.prototype[EE.captureRejectionSymbol] = function(err) {
369
this.destroy(err);
370
371
372
-Readable.prototype[SymbolAsyncDispose] = function() {
+Readable.prototype[SymbolAsyncDispose] = async function() {
373
let error;
374
if (!this.destroyed) {
375
error = this.readableEnded ? null : new AbortError();
376
this.destroy(error);
377
378
- return new Promise((resolve, reject) => eos(this, (err) => (err && err !== error ? reject(err) : resolve(null))));
+ await new Promise((resolve, reject) => eos(this, (err) => (err && err !== error ? reject(err) : resolve(null))));
379
380
381
// Manually shove something into the read() buffer.
lib/internal/streams/writable.js
@@ -1149,13 +1149,13 @@ Writable.toWeb = function(streamWritable) {
1149
return lazyWebStreams().newWritableStreamFromStreamWritable(streamWritable);
1150
1151
1152
-Writable.prototype[SymbolAsyncDispose] = function() {
+Writable.prototype[SymbolAsyncDispose] = async function() {
1153
1154
1155
error = this.writableFinished ? null : new AbortError();
1156
1157
1158
- return new Promise((resolve, reject) =>
+ await new Promise((resolve, reject) =>
1159
eos(this, (err) => (err && err.name !== 'AbortError' ? reject(err) : resolve(null))),
1160
);
1161