Repository navigation
All versions of npm init hang on Node 8.1.0 #13557
Description
Activity
- addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Jun 8, 2017 yarn behaves the same
Reacted by 边城, Ahmad Bamieh, Slava, Karuppiah Natarajan, Dima, Renato Seiji Miawaki and Daisuke Kondo- addedreadlineIssues and PRs related to the built-in readline module.Issues and PRs related to the built-in readline module.and removed
on Jun 8, 2017 I can't seem to reproduce on
masteror8.1.0?The
WARNdoes seem to be on the wrong line though?Press ^C at any time to quit. package name: (npm-test) npm WARN init canceled 🐟 ~/D/h/npm-test>I'd be curious to see what e.g. the following patch prints pre/post 81ddeb9
diff --git a/lib/readline.js b/lib/readline.js index 6a1ed150d7..6113846c91 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -1039,6 +1039,8 @@ function emitKeypressEvents(stream, iface) { } else { stream.on('newListener', onNewListener); } + iface.on('close', () => process._rawDebug('## CLOSE')) + stream.on('data', () => process._rawDebug('## DATA')) if (iface) { iface.once('close', () => { stream.removeListener('data', onData); }); }
@Fishrock123 I’m not sure I’m reading your output correctly – you first have to enter the package name, only after that I can’t quite anymore.
Oops. 🙊
It appears a
closeis emitted after pressingenterunder normal circumstances...package name: (npm-test) ## DATA ## CLOSE version: (0.0.0) ## DATA description: ## DATA npm WARN init canceled@Fishrock123 Apparently,
npm init(or rather thereadmodule) creates a new readline instance per question that it asks…@jasnell You’re right,
reverting is a bit silly, this is easy to fix (in a somewhat obvious way, in hindsight):okay, no, the original patch was incorrect and should be reverted.--- a/lib/readline.js +++ b/lib/readline.js @@ -1040,7 +1040,11 @@ function emitKeypressEvents(stream, iface) { stream.on('newListener', onNewListener); } if (iface) { - iface.once('close', () => { stream.removeListener('data', onData); }); + iface.once('close', () => { + stream[KEYPRESS_DECODER] = null; + stream[ESCAPE_DECODER] = null; + stream.removeListener('data', onData); + }); } }
I’ll have a PR and tests up in a bit.
@iarna Naaaaw! 💙
Reacted by Ben Newman and Alan TaiApparently,
npm init(or rather thereadmodule) creates a new readline instance per question that it asks…While that seems inefficient,
readlinedoes apparently emitcloseat the end of each line: https://nodejs.org/dist/latest-v8.x/docs/api/readline.html#readline_event_close(Which leads me to believe the patch above may be a bit inefficient too? We can discuss in a PR.)
While that seems inefficient,
readlinedoes apparently emitcloseat the end of each line: https://nodejs.org/dist/latest-v8.x/docs/api/readline.html#readline_event_closeAre you sure? I don’t really read the docs as stating that…
That definitely seems like a bug then. It really should not be emitting close at that point. Let's see if we can fix that issue quickly before reverting the other commit
It really should not be emitting close at that point.
It doesn’t, it’s the
readmodule that closes the readline instance explicitly after having read the answer.Reacted by Jeremiah SenkpielPR to fix/revert: #13560
Reacted by Darcy Clarke, Gibson Fahnestock, Parham Alvani, Manpreet Singh, Alexey Mikhaylov, Ben Newman, Luke Deen Taylor, Yahor Siarheyenka, Courtney Faulkner, Alan Tai and 10 moreReacted by Steven, Daniel Shneyder, Matt Black, Bruno Devaux and Nong (Ron) Wang- addedregressionIssues related to regressions.Issues related to regressions.
on Jun 8, 2017 Following sample code is broken, waiting for you @addaleax !
const readline = require('readline') function prompt(opts, cb) { var input = process.stdin var output = process.stdout var terminal = !!(output.isTTY) var rlOpts = { input, output, terminal } var rl = readline.createInterface(rlOpts) rl.setPrompt(opts.prompt) rl.prompt() rl.on('line', function(line){ rl.close() cb(null, line); }) } const foo = function() { prompt( {prompt : "#>" }, function(err, line ){ console.log("Got", err, line); foo(); }) } foo();
@131 see #13560 (comment), it'll be fixed in the next v8.x release, scheduled for next Tuesday.
Reacted by James Cuénod, Jacob Mason, Allan Kimmer Jensen, Hendrik Belitz, Mark Apinis, Marco Scannadinari, Steven, Tad Lispy, Andrea Richiardi, Alexandru Sfirlogea and 1 moreReacted by Bernard Mordan, Grégoire Lodi, Marcio Puga, Abhinav Gauniyal and Zhong-weiReacted by Maisie Bell, Marco Scannadinari, Tad Lispy, Alexandru Sfirlogea and Marcus Bergman- added a commit that references this issue
on Jun 10, 2017 i'm still facing this issue guys
@Bamieh As described above, upgrade Node to the latest version and you will be fine.
@addaleax true, it gets fixed when upgrading node, i only upgraded npm before and it didnt work. thanks
This is still affecting the loopback-cli
It freezes after giving the application name...
node version - v10.7.0
npm version=6.1.0
loopback- 4.2.0
OS- windows10anyone help please?
Thanks
Reacted by John Desrosiers- added a commit that references this issue
on Jul 27, 2026
To reproduce, with Node 8.1.0 and any version of npm (we've explicitly tested w/ 2, 3, 4 & 5):
At the prompt for version Node stops accepting input and doesn't respond to ^Z or ^C. (It does respond to
kill -STOPandkill -INT. Continuing the process after a STOP results in keyboard input being echoed but the process still does not run.)