summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/fs.js2
-rw-r--r--lib/internal/fs/promises.js56
-rw-r--r--lib/internal/http2/core.js6
3 files changed, 36 insertions, 28 deletions
diff --git a/lib/fs.js b/lib/fs.js
index 34517a17da..d5c7ea70d8 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -1964,7 +1964,7 @@ Object.defineProperties(fs, {
enumerable: true,
get() {
if (promises === null)
- promises = require('internal/fs/promises');
+ promises = require('internal/fs/promises').exports;
return promises;
}
}
diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js
index 7660ff66be..31613780a7 100644
--- a/lib/internal/fs/promises.js
+++ b/lib/internal/fs/promises.js
@@ -46,7 +46,7 @@ const {
const pathModule = require('path');
const { promisify } = require('internal/util');
-const kHandle = Symbol('handle');
+const kHandle = Symbol('kHandle');
const { kUsePromises } = binding;
const getDirectoryEntriesPromise = promisify(getDirents);
@@ -507,29 +507,33 @@ async function readFile(path, options) {
}
module.exports = {
- access,
- copyFile,
- open,
- opendir: promisify(opendir),
- rename,
- truncate,
- rmdir,
- mkdir,
- readdir,
- readlink,
- symlink,
- lstat,
- stat,
- link,
- unlink,
- chmod,
- lchmod,
- lchown,
- chown,
- utimes,
- realpath,
- mkdtemp,
- writeFile,
- appendFile,
- readFile
+ exports: {
+ access,
+ copyFile,
+ open,
+ opendir: promisify(opendir),
+ rename,
+ truncate,
+ rmdir,
+ mkdir,
+ readdir,
+ readlink,
+ symlink,
+ lstat,
+ stat,
+ link,
+ unlink,
+ chmod,
+ lchmod,
+ lchown,
+ chown,
+ utimes,
+ realpath,
+ mkdtemp,
+ writeFile,
+ appendFile,
+ readFile,
+ },
+
+ FileHandle
};
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index d2701dfb84..11d677c5f6 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -82,6 +82,7 @@ const {
hideStackFrames
} = require('internal/errors');
const { validateNumber, validateString } = require('internal/validators');
+const fsPromisesInternal = require('internal/fs/promises');
const { utcDate } = require('internal/http');
const { onServerStream,
Http2ServerRequest,
@@ -2523,7 +2524,10 @@ class ServerHttp2Stream extends Http2Stream {
this[kState].flags |= STREAM_FLAGS_HAS_TRAILERS;
}
- validateNumber(fd, 'fd');
+ if (fd instanceof fsPromisesInternal.FileHandle)
+ fd = fd.fd;
+ else if (typeof fd !== 'number')
+ throw new ERR_INVALID_ARG_TYPE('fd', ['number', 'FileHandle'], fd);
debugStreamObj(this, 'initiating response from fd');
this[kUpdateTimer]();