node and then press enterThe cursor should be visible immediatelly after moving (to the left or to the right). For example, command prompt automatically displays the cursor after it has been moved. The cursor has blink rate, but after user moves it, it should be visible no matter if at the given moment the blink rate timeout suggest that it should be visible or invisible.
After moving, the cursor becomes hidden. It makes navigating through the code very hard. Users need to wait one second after moving in order to find out where the cursor currently is. Using CTRL+← helps a bit skipping whole words, but it is still very hard to navigate if the code is large.
I am pretty sure it is. The reason I think it is Node.js issue and not issue with command prompt is because other programs which provide REPL functionalities properly display the cursor after moving (reset the cursor blink rate to visible state). For example, Python 3.6 properly handles it.
I think no.
@nodejs/platform-windows
Sorry, I can't reproduce this.
Does this also happen with other Node versions? Are you using some console emulators (like ConEmu)? Could you maybe provide a screenshot of the issue?
@bzoz
Does this also happen with other Node versions?
Reproduces with all versions from node 4 to node 10 (not tested below node 4).
Are you using some console emulators
No, just pure command prompt.
Could you maybe provide a screenshot of the issue?
Not sure how screenshot can help, so I'm providing screen recording. It is recorded on windows 8.1, which means that it also reproduces on windows 8.1
I can't reproduce this either. Does it happen every time you try it?
Until we are able to reproduce your problem, let's make sure that it is not caused by a third-party application. Could you post the output of listdlls -v PID for the PIDs of cmd.exe, conhost.exe and node.exe while node is running? (Preferably on a 64 bit Windows 10 system with a 64 bit node build, if possible.) You can find the PIDs using procexp, both tools are provided as part of the Sysinterals Suite.
@tniessen
Does it happen every time you try it?
Yes. Here are the outputs of listdlls -v PID: outputs.zip
Any updates on this? I mean, it is one week from posting and still nobody is able to reproduce? Weird...
@advanceddeveloper Sorry, I still was not able to reproduce the problem. The DLL list looks normal, I just had you check because we had issues with third-party applications injecting DLLs into node / the console in the past.
Is someone else from @nodejs/platform-windows able to reproduce?
It seems I can reproduce a tiny delay on Windows 7 x64 with cmd.exe:
Screenshot:

The "tiny" delay that can be seen on the screenshot is, as I can tell exactly half-time of the blink rate, which means that the visibility state of the cursor in node.js repl is set to invisible immediatelly after moving, while in batch repl (cmd itself) or python repl cursor state is set to visible after moving. I think vsemozhetbyt's screenshot confirms the issue (I also checked on windows 7 32 and 64 bit, but on virtual machine, and able to reproduce).
Also, notice that the blink rate may vary (on my pc it is 1 second), so the "tiny" delay becomes "not so tiny" delay.
I don't know if we can do anything about it. I've took a quick look into Python code to see if there is anything related that could be used to improve Node, but could not find anything.
@advanceddeveloper can you try adjusting cursor blink rate in the Keyboard properties in the Control Panel? Other than that I don't think we can do anything in Node to fix this.
Can you try adjusting cursor blink rate in the Keyboard properties in the Control Panel?
I really like my 1sec blink rate and don't want to change it.
I've took a quick look into Python code to see if there is anything related that could be used to improve Node, but could not find anything.
Since all programs that use REPL (not only python) which I tested so far properly handle cursor movement, I guess that these programs don't do anything special, but probably Node.js does something (I suppose unintentionally) that hides the cursor after moving. As I know, command prompt and powershell by default show the cursor, so if the cursor after moving is hidden, it probably means that the application itself (here node.js) hides the cursor.
I don't know if we can do anything about it.
I'm sorry, but I can't believe that this is impossible to fix. Either Node.js or some of it's libraries affect cursor behavior. As I said, all other programs properly handle it (even programs written in C and compiled with gcc (which also means that no extra code is needed to properly handle cursor movement)), so even if some library which is used by node.js creates this weird behavior, I am sure Node.js can override it and implement correct behavior. I mean, currently it is very hard (read: impossible) to navigate in the REPL.
I can reproduce this issue on Windows 7 but not Windows 10.
Did more investigation: Python just uses fgets. We are running the console in raw mode and move the cursor ourselves. Thanks to this we support some fancy commands, persistent history, tab auto competition, etc.
The readline module is moving the cursor by itself when arrow keys are used. I can only guess that moving the cursor restarts blinking animation loop and thus we have a cursor that disappears.
Able to reproduce with reported v10.0.0 and latest v10.6.0 using Windows 8.1 x64.
I have the exact same problem. Node v8.11.1. I tried both command promt and powershell. I'm using Windows 7.
Calling SetConsoleCursorInfo with CONSOLE_CURSOR_INFO::bVisible set to TRUE after moving the cursor would probably solve this problem.
@Hakerh400: tried that (added a call to uv_tty_set_cursor_visibility in uv_tty_move_caret) - does not help.
I don't know if we can do anything else besides suggesting using ConEmu in which the cursor is visible when moving.
I have the same issue, which has been present with every version of Node I've used. I'm running Windows 7 32-bit. My current version of Node is 10.6.0. I get the disappearing cursor no matter whether I start Node through cmd, PowerShell, Git Bash, or the node.exe executable directly.
We've seen the same problem in Julia, and a quick google search reveals others with the problem too. From some more googling, I think MS may have fixed this bug in https://github.com/Microsoft/console/issues/269
Thanks for doing that digging @vtjnash! I'm not entirely sure that console bug is the same as this one though, at least from the initial report in that issue you linked to:
Type into windows cmd. Cursor disappears and does not reappear.
In the Node REPL, the cursor does consistently reappear. The issue is that its blink cycle restarts in the hidden state whenever the cursor is moved, so it remains hidden until the cursor stops moving and half the blink rate's time elapses.
(Powershell apears unaffected though)
As I mentioned in an earlier comment, I get exactly the same issue whether I start the Node REPL from cmd, PowerShell, or Git Bash.
Is the problem you've been running into with Julia closer to this behavior?
I'm not familiar with the implementation of the REPL, so I could be way of track, but these might be some helpful bits of info:
cmd, PowerShell, or Git Bash, it's only in the Node REPL.ts-node.From my (admittedly uninformed) observations: The only places I see the disappearing cursor problem is when running Node. I don't see it in any other console-related interface, which seems to suggest that the issue stems from something in Node's codebase or dependencies.
If your research turned up any examples that match this specific behavior more closely, it might be helpful if you would share them here to help in tracking down a solution.
I've seen that depending on various options (such as turning on the legacy rendering and the capabilities of the program driving the console) the effect can vary from almost instant (visible only as screen tearing) to full loss of cursor for many seconds after all input stops. That all seems to be the fault of conhost though, since I don't see any option for a program to command the cursor to blink/stop. If you follow the link above, you can see some example screen caps of the different ways people have seen that problem manifest for various applications and settings.
https://github.com/Microsoft/console/issues/269 is an issue with Win10, this is a issue withe the Win7 console (the old, legacy one).
From what I found out:
For me (on Windows 10), the modern console can show undesirable cursor flickering, but the bad delays only happen with the legacy console enabled. But I see those same effects regardless of whether I'm running just cmd.exe or libuv. Additionally, I observe that changing the blink rate does affect this for me, as does disabling it altogether, if I'm using line mode (including through libuv), but does not significantly affect this delay when in "raw mode".
The original report was for Windows 10, so maybe there's multiple bugs here? I have a Win7 VM, but haven't booted it in years.
Multiple bugs, or maybe using legacy console in Win10?
This looks related to https://github.com/libuv/libuv/issues/852 and https://github.com/libuv/libuv/pull/866
No, those are not related, the issue is the console window itself. On older Windows, moving the cursor from the code restarts the blinking cycle to "not shown". There is nothing we can do about it, except to suggest using console emulator like ConEmu.
Python and other apps do not show this issue, because they are using consoles built-in "get line" functionality. Node uses its own custom method, which allows us to have history and autocompletion.
Besides switching REPL to use line mode (which I don't think will happen) I can't see anything that we can do about this issue.
This is an issue only on older Windows, so I suggest just closing. Windows 7 support ends in January and almost no one uses Windows 8.1.
They will have to upgrade within the next 5 months, and I guarantee their next OS won't be Windows 8.1.
@bzoz already explained that other REPLs don't have this problem because they are more primitive.
Most other languages do not offer as feature-rich REPL as Node does.
I don't think there is anything sensible we can do here. Upgrading Windows or installing ConEmu is a valid solution. We could make a line-mode REPL but I don't think it is worth the effort.
I'm going to close this issue.
Most helpful comment
Most other languages do not offer as feature-rich REPL as Node does.
I don't think there is anything sensible we can do here. Upgrading Windows or installing ConEmu is a valid solution. We could make a line-mode REPL but I don't think it is worth the effort.
I'm going to close this issue.