nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.52k stars 29.03k forks source link

Speculative execution in REPL shows TypeError overwriting input #54504

Open mikesamuel opened 3 weeks ago

mikesamuel commented 3 weeks ago

Version

v22.6.0

Platform

Darwin Mikes-MacBook-Pro.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

As shown in attached video:

  1. From command line run node
  2. At the prompt, enter the following without hitting enter: '\v'.codeAt(0)
  3. As soon as the close parenthesis is typed, see:

TypeError: " ".codeAt is not a function

The vertical tab pulled the cursor away from the prompt line.

Mitigation: Hitting Ctrl-l resets the cursor to expected.

https://github.com/user-attachments/assets/1e77ab0a-7097-420a-a598-08dc16e363a3

How often does it reproduce? Is there a required condition?

Occurs every time

What is the expected behavior? Why is that the expected behavior?

The REPL cursor should stay on the prompt line, not overlap any error message due to speculative execution.

What do you see instead?

The vertical tab pulled the cursor away from the prompt line.

Additional information

No response

RedYetiDev commented 3 weeks ago
$ node
Welcome to Node.js v22.7.0.
Type ".help" for more information.
> "\v".notAFunction()
TypeError: "
            ".notAFunction is not a function