Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readline: fix question stack overflow #43320

Merged
merged 2 commits into from
Jun 12, 2022

Conversation

chapko
Copy link
Contributor

@chapko chapko commented Jun 5, 2022

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.

Reproducible example:

const rli = require('readline').createInterface(process.stdin, process.stdout);
const signal = new AbortController().signal;

rli.question('Hello? ', { signal }, (answer) => {
    console.log(`Hello, ${answer}`);
});

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.
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. readline Issues and PRs related to the built-in readline module. labels Jun 5, 2022
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Can you also add a test to test/parallel/test-readline-promises-interface.js please?

@chapko chapko force-pushed the fix-readline-stackoverflow branch from 1357094 to 35fda91 Compare June 5, 2022 11:52
@chapko
Copy link
Contributor Author

chapko commented Jun 5, 2022

@aduh95 yes, just added an identical test to the readline/promises suite

UPD: Also added a similar test for the promisified question (it wasn't covered).

@aduh95
Copy link
Contributor

aduh95 commented Jun 5, 2022

/cc @nodejs/readline

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jun 5, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 5, 2022
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 9, 2022
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 9, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/43320
✔  Done loading data for nodejs/node/pull/43320
----------------------------------- PR info ------------------------------------
Title      readline: fix question stack overflow (#43320)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     chapko:fix-readline-stackoverflow -> nodejs:master
Labels     readline, author ready, needs-ci
Commits    2
 - readline: fix question stack overflow
 - readline: add test for promisified question
Committers 1
 - Eugene Chapko 
PR-URL: https://github.com/nodejs/node/pull/43320
Reviewed-By: Antoine du Hamel 
Reviewed-By: Colin Ihrig 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/43320
Reviewed-By: Antoine du Hamel 
Reviewed-By: Colin Ihrig 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Sun, 05 Jun 2022 07:24:05 GMT
   ✔  Approvals: 2
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/43320#pullrequestreview-996012891
   ✔  - Colin Ihrig (@cjihrig) (TSC): https://github.com/nodejs/node/pull/43320#pullrequestreview-996013510
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-06-05T15:05:39Z: https://ci.nodejs.org/job/node-test-pull-request/44369/
- Querying data for job/node-test-pull-request/44369/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/master up to date...
From https://github.com/nodejs/node
 * branch                  master     -> FETCH_HEAD
✔  origin/master is now up-to-date
- Downloading patch for 43320
From https://github.com/nodejs/node
 * branch                  refs/pull/43320/merge -> FETCH_HEAD
✔  Fetched commits as 595ce9dac63c..473f03c07014
--------------------------------------------------------------------------------
[master da9e2e4e2c] readline: fix question stack overflow
 Author: Eugene Chapko 
 Date: Sun Jun 5 10:51:55 2022 +0400
 3 files changed, 24 insertions(+), 1 deletion(-)
[master c979bdf2f7] readline: add test for promisified question
 Author: Eugene Chapko 
 Date: Sun Jun 5 16:22:34 2022 +0400
 2 files changed, 15 insertions(+), 2 deletions(-)
   ✔  Patches applied
There are 2 commits in the PR. Attempting autorebase.
Rebasing (2/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
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: #43320
Reviewed-By: Antoine du Hamel duhamelantoine1995@gmail.com
Reviewed-By: Colin Ihrig cjihrig@gmail.com

[detached HEAD 82bb5d4087] readline: fix question stack overflow
Author: Eugene Chapko eugene.chapko@gmail.com
Date: Sun Jun 5 10:51:55 2022 +0400
3 files changed, 24 insertions(+), 1 deletion(-)
Rebasing (3/4)
Rebasing (4/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
readline: add test for promisified question

PR-URL: #43320
Reviewed-By: Antoine du Hamel duhamelantoine1995@gmail.com
Reviewed-By: Colin Ihrig cjihrig@gmail.com

[detached HEAD de86c7729c] readline: add test for promisified question
Author: Eugene Chapko eugene.chapko@gmail.com
Date: Sun Jun 5 16:22:34 2022 +0400
2 files changed, 15 insertions(+), 2 deletions(-)

Successfully rebased and updated refs/heads/master.

ℹ Use --fixupAll option, squash the PR manually or land the PR from the command line.

https://github.com/nodejs/node/actions/runs/2467622683

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 12, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 12, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/43320
✔  Done loading data for nodejs/node/pull/43320
----------------------------------- PR info ------------------------------------
Title      readline: fix question stack overflow (#43320)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     chapko:fix-readline-stackoverflow -> nodejs:master
Labels     readline, author ready, needs-ci, commit-queue-failed
Commits    2
 - readline: fix question stack overflow
 - readline: add test for promisified question
Committers 1
 - Eugene Chapko 
PR-URL: https://github.com/nodejs/node/pull/43320
Reviewed-By: Antoine du Hamel 
Reviewed-By: Colin Ihrig 
Reviewed-By: James M Snell 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/43320
Reviewed-By: Antoine du Hamel 
Reviewed-By: Colin Ihrig 
Reviewed-By: James M Snell 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Sun, 05 Jun 2022 07:24:05 GMT
   ✔  Approvals: 3
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/43320#pullrequestreview-996012891
   ✔  - Colin Ihrig (@cjihrig) (TSC): https://github.com/nodejs/node/pull/43320#pullrequestreview-996013510
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/43320#pullrequestreview-1003513187
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-06-09T10:19:18Z: https://ci.nodejs.org/job/node-test-pull-request/44369/
- Querying data for job/node-test-pull-request/44369/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/master up to date...
From https://github.com/nodejs/node
 * branch                  master     -> FETCH_HEAD
✔  origin/master is now up-to-date
- Downloading patch for 43320
From https://github.com/nodejs/node
 * branch                  refs/pull/43320/merge -> FETCH_HEAD
✔  Fetched commits as fab676ec5536..473f03c07014
--------------------------------------------------------------------------------
Auto-merging lib/readline.js
[master 214108da34] readline: fix question stack overflow
 Author: Eugene Chapko 
 Date: Sun Jun 5 10:51:55 2022 +0400
 3 files changed, 24 insertions(+), 1 deletion(-)
[master ebad194dac] readline: add test for promisified question
 Author: Eugene Chapko 
 Date: Sun Jun 5 16:22:34 2022 +0400
 2 files changed, 15 insertions(+), 2 deletions(-)
   ✔  Patches applied
There are 2 commits in the PR. Attempting autorebase.
Rebasing (2/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
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: #43320
Reviewed-By: Antoine du Hamel duhamelantoine1995@gmail.com
Reviewed-By: Colin Ihrig cjihrig@gmail.com
Reviewed-By: James M Snell jasnell@gmail.com

[detached HEAD a50e8f2ba6] readline: fix question stack overflow
Author: Eugene Chapko eugene.chapko@gmail.com
Date: Sun Jun 5 10:51:55 2022 +0400
3 files changed, 24 insertions(+), 1 deletion(-)
Rebasing (3/4)
Rebasing (4/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
readline: add test for promisified question

PR-URL: #43320
Reviewed-By: Antoine du Hamel duhamelantoine1995@gmail.com
Reviewed-By: Colin Ihrig cjihrig@gmail.com
Reviewed-By: James M Snell jasnell@gmail.com

[detached HEAD 1b3f2d826b] readline: add test for promisified question
Author: Eugene Chapko eugene.chapko@gmail.com
Date: Sun Jun 5 16:22:34 2022 +0400
2 files changed, 15 insertions(+), 2 deletions(-)

Successfully rebased and updated refs/heads/master.

ℹ Use --fixupAll option, squash the PR manually or land the PR from the command line.

https://github.com/nodejs/node/actions/runs/2483034882

@aduh95 aduh95 added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jun 12, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 12, 2022
@nodejs-github-bot nodejs-github-bot merged commit 2efeb5c into nodejs:master Jun 12, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 2efeb5c

italojs pushed a commit to italojs/node that referenced this pull request Jun 12, 2022
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: nodejs#43320
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams pushed a commit that referenced this pull request Jun 13, 2022
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: #43320
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@danielleadams danielleadams mentioned this pull request Jun 13, 2022
danielleadams pushed a commit that referenced this pull request Jun 13, 2022
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: #43320
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. readline Issues and PRs related to the built-in readline module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants