Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorXuguang Mei <meixg@foxmail.com>2022-04-08 13:17:03 +0300
committerGitHub <noreply@github.com>2022-04-08 13:17:03 +0300
commitd36b60e69a00b60b8f2c260b8c376c9a16a152df (patch)
tree6a55cf5d3967bd2290d81f949ee5e3348e9977ae /lib
parent0bac5478eb9d242719f7e19f44db03d36c3647d8 (diff)
readline: fix question still called after closed
resolve: https://github.com/nodejs/node/issues/42450 PR-URL: https://github.com/nodejs/node/pull/42464 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/errors.js1
-rw-r--r--lib/internal/readline/interface.js8
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index 5f75c0290b3..a5c64080a59 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -1627,6 +1627,7 @@ E('ERR_UNSUPPORTED_ESM_URL_SCHEME', (url, supported) => {
msg += `. Received protocol '${url.protocol}'`;
return msg;
}, Error);
+E('ERR_USE_AFTER_CLOSE', '%s was closed', Error);
// This should probably be a `TypeError`.
E('ERR_VALID_PERFORMANCE_ENTRY_TYPE',
diff --git a/lib/internal/readline/interface.js b/lib/internal/readline/interface.js
index b5a5455ed3d..47e5ca580ab 100644
--- a/lib/internal/readline/interface.js
+++ b/lib/internal/readline/interface.js
@@ -38,7 +38,10 @@ const {
const { codes } = require('internal/errors');
-const { ERR_INVALID_ARG_VALUE } = codes;
+const {
+ ERR_INVALID_ARG_VALUE,
+ ERR_USE_AFTER_CLOSE,
+} = codes;
const {
validateAbortSignal,
validateArray,
@@ -398,6 +401,9 @@ class Interface extends InterfaceConstructor {
}
question(query, cb) {
+ if (this.closed) {
+ throw new ERR_USE_AFTER_CLOSE('readline');
+ }
if (this[kQuestionCallback]) {
this.prompt();
} else {