Skip to content

repl: handle dot commands in multiline input#63889

Open
Diyoncrz18 wants to merge 2 commits into
nodejs:mainfrom
Diyoncrz18:fix-repl-dot-commands-multiline-63864
Open

repl: handle dot commands in multiline input#63889
Diyoncrz18 wants to merge 2 commits into
nodejs:mainfrom
Diyoncrz18:fix-repl-dot-commands-multiline-63864

Conversation

@Diyoncrz18

Copy link
Copy Markdown

Fixes: #63864

This restores REPL dot-command handling when a command is entered from a TTY multiline continuation prompt.

Since TTY multiline input can arrive as one editable buffer like function a() {\n.break, the previous command detection only checked the beginning of the full buffer and sent .break, .help, and .exit to JavaScript evaluation, producing Uncaught SyntaxError: Unexpected token '.'.

This change checks the newest physical line for registered REPL dot-commands in the TTY multiline case, keeps the preceding lines in the existing buffered-command path, and dispatches the dot-command through the existing REPL keyword handling.

Added regression coverage for:

  • .break after a recoverable multiline input
  • .help after a recoverable multiline input
  • .exit after a recoverable multiline input

Validation:

  • node --check lib/repl.js
  • node --check test/parallel/test-repl-multiline.js
  • git diff --check

Note: I could not run python tools/test.py test/parallel/test-repl-multiline.js locally because this Windows checkout does not currently have a built Node binary.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem. labels Jun 13, 2026
Comment thread lib/repl.js Outdated
// prompt, while keeping the previous lines buffered.
if (self.terminal &&
!self[kBufferedCommandSymbol] &&
StringPrototypeIncludes(cmd, '\n')) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tested the changes on Windows, and the issue does not appear to be resolved yet. From my debugging, it looks like this condition-based check is not getting satisfied, so the logic may need additional updates.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for testing this on Windows. You were right — the previous guard missed a real continuation-prompt shape because the buffered command can already be set.

I've updated the fix so TTY multiline input still checks the newest physical line for registered REPL dot commands even when a buffered command exists. If the buffer is already active, it is preserved; otherwise the previous physical lines are moved into the existing REPL buffer. The command is then dispatched through the existing REPL keyword handling path.

I also adjusted the regression tests to cover both the full editable multiline buffer path and the buffered continuation prompt path for .break, .help, and .exit.

Validation run locally:

  • node --check lib/repl.js
  • node --check test/parallel/test-repl-multiline.js
  • git diff --check

I still cannot run the full test runner locally because this checkout does not currently have a built Node binary (Release/node.exe is missing).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While digging more I figured out an alternate fix and created a PR for it.
#63911

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe you should try to install Rust in your Windows. Recent changes for Temporal API need rust and cargo to build Node binary.

SudhansuBandha added a commit to SudhansuBandha/node that referenced this pull request Jun 14, 2026
Fixes: nodejs#63864
Refs: nodejs#63889

Update conditional logic to correctly handle dot commands in multiline REPL input
SudhansuBandha added a commit to SudhansuBandha/node that referenced this pull request Jun 14, 2026
Fixes: nodejs#63864
Refs: nodejs#63889

Update conditional logic to correctly handle dot commands in multiline REPL input
SudhansuBandha added a commit to SudhansuBandha/node that referenced this pull request Jun 14, 2026
Fixes: nodejs#63864
Refs: nodejs#63889

Update conditional logic to correctly handle dot commands in multiline REPL input
SudhansuBandha added a commit to SudhansuBandha/node that referenced this pull request Jun 14, 2026
Update conditional logic to correctly handle dot commands
in multiline REPL input

Fixes: nodejs#63864
Refs: nodejs#63889
Signed-off-by: SudhansuBandha bandhasudhansu@gmail.com
SudhansuBandha added a commit to SudhansuBandha/node that referenced this pull request Jun 14, 2026
Update conditional logic to correctly handle dot commands
in multiline REPL input

Fixes: nodejs#63864
Refs: nodejs#63889
Signed-off-by: SudhansuBandha bandhasudhansu@gmail.com
SudhansuBandha added a commit to SudhansuBandha/node that referenced this pull request Jun 14, 2026
Update conditional logic to correctly handle dot commands
in multiline REPL input

Fixes: nodejs#63864
Refs: nodejs#63889
Signed-off-by: SudhansuBandha <bandhasudhansu@gmail.com>
SudhansuBandha added a commit to SudhansuBandha/node that referenced this pull request Jun 14, 2026
Update conditional logic to correctly handle dot commands
in multiline REPL input

Fixes: nodejs#63864
Refs: nodejs#63889
Signed-off-by: SudhansuBandha <bandhasudhansu@gmail.com>
SudhansuBandha added a commit to SudhansuBandha/node that referenced this pull request Jun 14, 2026
Update conditional logic to correctly handle dot commands
in multiline REPL input

Fixes: nodejs#63864
Refs: nodejs#63889
Signed-off-by: SudhansuBandha <bandhasudhansu@gmail.com>
@Diyoncrz18

Copy link
Copy Markdown
Author

Thanks for taking another look and for opening #63911. I'll review the alternate approach and compare it with my current patch, especially around the buffered continuation prompt path and the regression coverage for .break, .help, and .exit.

Thanks also for the Rust/Cargo heads-up. I'll install Rust on my Windows setup so I can build the current Node tree and run the full REPL test locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

REPL: dot-commands produce SyntaxError inside multi-line input

3 participants