mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
readline: fix question stack overflow
This commit fixes readline interface's question callback wrapping when it is being called with `signal` option. Previous version completely overwrites passed callback and throws "Maximum call stack size exceeded" error. PR-URL: https://github.com/nodejs/node/pull/43320 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
112518fb1d
commit
7e8a00a26d
3 files changed
+37
-1
No files matched your search
+2
-1
@@ -148,9 +148,10 @@ Interface.prototype.question = function(query, options, cb) {
|
||||
const cleanup = () => {
|
||||
options.signal.removeEventListener(onAbort);
|
||||
};
|
||||
const originalCb = cb;
|
||||
cb = typeof cb === 'function' ? (answer) => {
|
||||
cleanup();
|
||||
return cb(answer);
|
||||
return originalCb(answer);
|
||||
} : cleanup;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user