Skip to content

readline: add stricter validation for functions called after closed (second attempt) #58283

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

Conversation

dario-piotrowicz
Copy link
Member

This PR makes it so that calling pause(), resume() or write() on a closed readline interface results in ERR_USE_AFTER_CLOSE errors being thrown (following the same behavior as question())


Note

This PR reintroduces the changes committed in #57680 but reverted in #58024 they also include @lpinca's suggested test changes to prevent test flakiness.

The reason why this was reverted was because of REPL still calling pause() and resume() even after it has been closed, which I am addressing that here (the lib repl files changes are specifically for that), just to be extra sure I am also adding the new test/parallel/test-repl-close.js test dedicated to making sure that closing a REPL does not result in errors (this test is not necessary since the error would be caught by test/parallel/test-repl-import-referrer.js anyways but I do think that it's nice to have a dedicated test just for this, if people disagree I'm happy to remove the new test file).


Fixes: #57678

@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. repl Issues and PRs related to the REPL subsystem. labels May 11, 2025
@dario-piotrowicz dario-piotrowicz changed the title readline: add stricter validation for functions called after closed readline: add stricter validation for functions called after closed (second attempt) May 11, 2025
@dario-piotrowicz dario-piotrowicz force-pushed the dario/2/readline-after-close-checks branch from 1452b63 to 9762ece Compare May 11, 2025 20:25
Copy link

codecov bot commented May 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.19%. Comparing base (4a86be2) to head (9762ece).
Report is 72 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58283      +/-   ##
==========================================
+ Coverage   90.18%   90.19%   +0.01%     
==========================================
  Files         631      631              
  Lines      186687   186700      +13     
  Branches    36663    36667       +4     
==========================================
+ Hits       168355   168397      +42     
+ Misses      11124    11106      -18     
+ Partials     7208     7197      -11     
Files with missing lines Coverage Δ
lib/internal/main/repl.js 94.02% <ø> (-0.09%) ⬇️
lib/internal/readline/interface.js 97.27% <100.00%> (+0.01%) ⬆️
lib/internal/repl/history.js 88.58% <100.00%> (+0.12%) ⬆️
lib/repl.js 94.98% <100.00%> (ø)

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lpinca lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label May 12, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 12, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@dario-piotrowicz dario-piotrowicz added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 12, 2025
@dario-piotrowicz
Copy link
Member Author

@lpinca would you be able to give this PR a quick review? 🙂 🙏

Copy link
Member

@lpinca lpinca left a comment

Choose a reason for hiding this comment

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

RSLGTM

@dario-piotrowicz dario-piotrowicz added the commit-queue Add this label to land a pull request using GitHub Actions. label May 18, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 18, 2025
@nodejs-github-bot nodejs-github-bot merged commit 39ab68b into nodejs:main May 18, 2025
64 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 39ab68b

@dario-piotrowicz dario-piotrowicz deleted the dario/2/readline-after-close-checks branch May 18, 2025 19:53
@dario-piotrowicz
Copy link
Member Author

thanks @lpinca 🫶

targos pushed a commit that referenced this pull request May 31, 2025
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. needs-ci PRs that need a full CI run. readline Issues and PRs related to the built-in readline module. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

readline hangs on writes after close
4 participants