fix(ext/node): multiple readline improvements#32538
Merged
bartlomieju merged 1 commit intodenoland:mainfrom Mar 9, 2026
Merged
fix(ext/node): multiple readline improvements#32538bartlomieju merged 1 commit intodenoland:mainfrom
bartlomieju merged 1 commit intodenoland:mainfrom
Conversation
- Fix tab completion column formatting (Math.max.apply was missing args) - Fix historySize validation to throw ERR_OUT_OF_RANGE for negative/NaN values and ERR_INVALID_ARG_TYPE for non-number values - Implement kill ring with yank (Ctrl+Y) and yank-pop (Meta+Y) - Implement undo (Ctrl+_) and redo (Ctrl+^) - Fix write() to throw ERR_USE_AFTER_CLOSE after close() - Fix question() abort signal cleanup: use correct removeEventListener args and prevent infinite recursion in callback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kajukitli
approved these changes
Mar 6, 2026
Contributor
kajukitli
left a comment
There was a problem hiding this comment.
lgtm — nice collection of readline fixes
verified:
Math.max(...completionsWidth)fix is correct (was missing spread)removeEventListenerfix — was indeed missing the event name arg- infinite recursion fix in callback wrapper by capturing
originalCb historySizevalidation now correctly distinguishes type vs range errors- kill ring + undo/redo implementation looks solid
minor nit: the undo stack could grow unbounded if users type a lot, but that's an edge case and matches how most editors work anyway
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several fixes and feature additions to the Node.js readline polyfill:
Math.max.apply(completionsWidth)was missing the array argument, causing all completions to display one-per-line instead of in columnshistorySizevalidation — now throwsERR_OUT_OF_RANGEfor negative/NaN values andERR_INVALID_ARG_TYPEfor non-number values (was incorrectly throwingERR_INVALID_ARG_VALUEfor all)Ctrl+Y) and yank-pop (Meta+Y)Ctrl+_/Ctrl+^)write()afterclose()to throwERR_USE_AFTER_CLOSEquestion()abort signal cleanup —removeEventListenerwas missing the event name arg, and the callback wrapper had an infinite recursion bugTest plan
cargo test --test node_compat test-readline— 18 pass (up from 16), 4 remaining failures are unrelated deeper issues (internal ESM module resolution, watermark data, promises abort-on-close)test-readline-tab-complete.jsandtest-readline-promises-tab-complete.js🤖 Generated with Claude Code