Skip to content

repl: redraw prompt after asynchronous console output - #65214

Open
inoway46 wants to merge 1 commit into
nodejs:mainfrom
inoway46:fix-repl-async-console-rejection-redraw
Open

repl: redraw prompt after asynchronous console output#65214
inoway46 wants to merge 1 commit into
nodejs:mainfrom
inoway46:fix-repl-async-console-rejection-redraw

Conversation

@inoway46

@inoway46 inoway46 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Fixes: #43074

Asynchronous console output can be written while the REPL is waiting for input, leaving readline's rendered prompt out of sync with its internal line and cursor state.

Register an internal post-write callback for REPL console instances and redraw the prompt after asynchronous output. This matches the output-then-redraw ordering used for REPL-managed asynchronous errors while preserving the current input and cursor position. It applies to both the default global console and isolated REPL contexts.

Add regression coverage for synchronous output, timer-driven asynchronous output, and cursor preservation in both contexts.

Manual verification

Scenario Before After
No active input Before: no active input After: no active input
With active input (aaaa) Before: active input is not redrawn After: active input is redrawn

@nodejs-github-bot nodejs-github-bot added console Issues and PRs related to the console subsystem. needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem. labels Aug 11, 2026
@inoway46
inoway46 marked this pull request as ready for review August 11, 2026 12:09
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.18182% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.32%. Comparing base (cb9bb66) to head (8d08fd2).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/console/constructor.js 84.21% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #65214    +/-   ##
========================================
  Coverage   90.31%   90.32%            
========================================
  Files         760      760            
  Lines      248532   248672   +140     
  Branches    46908    46941    +33     
========================================
+ Hits       224467   224603   +136     
+ Misses      15505    15477    -28     
- Partials     8560     8592    +32     
Files with missing lines Coverage Δ
lib/repl.js 93.07% <100.00%> (+0.13%) ⬆️
lib/internal/console/constructor.js 97.82% <84.21%> (-0.37%) ⬇️

... and 65 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.

@inoway46
inoway46 force-pushed the fix-repl-async-console-rejection-redraw branch 3 times, most recently from 4978e29 to 8d08fd2 Compare August 12, 2026 04:33
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

console Issues and PRs related to the console subsystem. needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Odd behavior with asynchronous console I/O in REPL

2 participants