kiln / flourish-sdk

The SDK for developing Flourish templates
Other
80 stars 16 forks source link

`flourish login` not working on Node 10.7.0 (WSL) #56

Closed hughsk closed 5 years ago

hughsk commented 5 years ago

Running flourish login breaks before it has the chance to send a login request to the server:

$ flourish login
Email:
Password:
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: shutdown ENOTCONN
    at ReadStream.Socket._final (net.js:369:25)
    at callFinal (_stream_writable.js:612:10)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

The error appears to be coming from the getpass package: the rtty stream emits an error the tick after it is closed.

This behavior only seems to be occurring for me when using Node v10 -- switching to Node v8 works around the issue. This makes me suspect that it's related to this bug in Node: https://github.com/nodejs/node/issues/22814

I also don't believe the getpass package works on Windows due to its reliance on /dev/tty instead of process.stdin and process.stdout. Perhaps the best solution is to replace getpass with a package that works in Windows and Node v10?

Thanks! :)

robinhouston commented 5 years ago

Perhaps the best solution is to replace getpass with a package that works in Windows and Node v10?

Do you know of one?

robinhouston commented 5 years ago

It looks like NPM uses the read package with the silent: true option – though this has its own problems, e.g. npm/read#34. Still, less bad than not working at all with Node 10!

This uses mute-stream to do the interesting part, i.e. reading the password without echoing it.