You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pasting code into node repl makes it exit on Windows #21773
I run node from cmd.exe, and simply paste this code using r-click:
var crypto = require('crypto');
function hmacN(N)
{
console.log(N);
}
The moment I paste it, node exists and I get this output:
Microsoft Windows [Version 10.0.17134.81]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\username>node
> var crypto = require('crypto');
undefined
> function hmacN(N)
... {
... console.log(N);
... }
undefined
>
C:\Users\username>
This used to work properly (e.g. it shouldn't exit), that's how I always test snippets by pasting them into node-repl console.
Interesting observation: if I paste incomplete code (without last }) then it won't exit and I need to manually complete it with the last brace and can continue. Or, if pasted block doesn't end with a new line character, then it will also won't exist and will wait for manual [ENTER] key press. Also, to confirm, the problem happens on 8.11.3 as well
I use awesome notepad++, so it's plain text.
current 10.0.7 has identical problem for me. I have a guess of what might be happening. Could it be that pasted text ends up with unix-style line endings ('\n' instead of '\r\n')? I'm connected from a mac and I RDP to Windows box where I work. I also tried to connect using teamviewer and I had identical problem. Perhaps, when text Ctrl+C'opied it gets converted to mac-style line endings in the buffer? That's the only guess I have.
However, I also RDP to this windows from another windows PC (with no Mac involved at all) and I end up with the same problem.
I have exactly the same problem. Independently from where I have copied a text from notepad++ or from this thread getting your piece of code literally the nodejs throws me out of REPL into w10 command prompt.
@pps83 There is not a solution but temporal remedy:
I used .editor command then pasted a snippet and typed ^D. The output is as follows:
(first goes an attempt without .editor then with it)
I:\nodejs>node
> var crypto = require('crypto');
undefined
> function hmacN(N)
... {
... console.log(N);
... }
undefined
>
I:\nodejs>node
> .editor
// Entering editor mode (^D to finish, ^C to cancel)
var crypto = require('crypto');
function hmacN(N)
{
console.log(N);
}
undefined
> hmacN(10)
10
undefined
>
It seems to only happen when more than one line break is in the pasted text. For example, pasting the following code will not cause the REPL to exit.
console.log('line 1')// <- there is a line break here
And here's the output.
C:\Users\Jordan>node
> console.log('line 1')
line 1
undefined
> _
However, this code will cause the REPL to exit.
console.log('line 1')console.log('line 2')// <- there is a line break here
And here's the output.
C:\Users\Jordan>node
> console.log('line 1')
line 1
undefined
> console.log('line 2') // <- there is a line break here
line 2
undefined
>
C:\Users\Jordan>_
@vuGitH's .editor workaround does prevent the REPL from exiting when pressing CTRL+D after pasting the code. Here's that output.
C:\Users\Jordan>node
> .editor
// Entering editor mode (^D to finish, ^C to cancel)
console.log('line 1')
console.log('line 2') // <- there is a line break here
line 1
line 2
undefined
> _
I just tried this on another computer running Windows 10.0.16299.547 and Node.js v8.11.4 and it did not exhibit this problem.
Then I tried it on another computer running Windows 10.0.17134.228 and Node.js v8.11.3 and it did exhibit the problem. So maybe something changed in Windows that's contributing to this bug.
Activity
bzoz commentedon Jul 12, 2018
I cannot reproduce this. Are you using any console emulator like ConEmu?
pps83 commentedon Jul 12, 2018
No, I use regular cmd.exe, plain vanilla win10 pro.
I tried to do the same on my home PC and I don't have that problem. What could possibly make it fail on my other PC?
lundibundi commentedon Jul 26, 2018
@pps83 could you please
This will allow to check the case when app you are copying from adds some additional characters (like Enter,Ctrl+d that will result in this behavior).
Also could you also check if it affects latest node? (10.7.0 at a time of writing).
pps83 commentedon Jul 26, 2018
I use awesome notepad++, so it's plain text.
current 10.0.7 has identical problem for me. I have a guess of what might be happening. Could it be that pasted text ends up with unix-style line endings ('\n' instead of '\r\n')? I'm connected from a mac and I RDP to Windows box where I work. I also tried to connect using teamviewer and I had identical problem. Perhaps, when text
Ctrl+C'opied it gets converted to mac-style line endings in the buffer? That's the only guess I have.However, I also RDP to this windows from another windows PC (with no Mac involved at all) and I end up with the same problem.
vuGitH commentedon Aug 27, 2018
I have exactly the same problem. Independently from where I have copied a text from notepad++ or from this thread getting your piece of code literally the nodejs throws me out of REPL into w10 command prompt.
vuGitH commentedon Aug 27, 2018
@pps83 There is not a solution but temporal remedy:
I used
.editorcommand then pasted a snippet and typed ^D. The output is as follows:(first goes an attempt without
.editorthen with it)This works for me. Try it on your PC.
vuGitH commentedon Aug 27, 2018
Another option:
try to paste.
jordanbtucker commentedon Sep 7, 2018
I'm having this issue too.
Both in PowerShell and CMD.
It seems to only happen when more than one line break is in the pasted text. For example, pasting the following code will not cause the REPL to exit.
And here's the output.
However, this code will cause the REPL to exit.
And here's the output.
@vuGitH's
.editorworkaround does prevent the REPL from exiting when pressing CTRL+D after pasting the code. Here's that output.jordanbtucker commentedon Sep 7, 2018
I just tried this on another computer running Windows 10.0.16299.547 and Node.js v8.11.4 and it did not exhibit this problem.
Then I tried it on another computer running Windows 10.0.17134.228 and Node.js v8.11.3 and it did exhibit the problem. So maybe something changed in Windows that's contributing to this bug.
vuGitH commentedon Sep 10, 2018
@jordanbtucker Jordan! Thank you for feedback!
bzoz commentedon Sep 11, 2018
It also reproduces on my box
bzoz commentedon Sep 11, 2018
Can be reproduced by:
Switching
breakEvalOnSiginttofalsemakes the problem go away./cc @nodejs/platform-windows @nodejs/repl
9 remaining items
tty: handle setRawMode errors
tty: handle setRawMode errors
cjihrig commentedon Sep 26, 2018
Reopening until the next libuv update.
deps: upgrade to libuv 1.23.2
deps: upgrade to libuv 1.23.2
deps: upgrade to libuv 1.23.2
tty, win: fix read stop for raw mode
deps: upgrade to libuv 1.23.2