question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setRawMode fails when running with non-TTY stdin

See original GitHub issue

Before the rest of the issue, I must say that Ink is amazing 👍

An issue I’ve encounted is that when Ink is running in a process where process.stdin.setRawMode is undefined (for instance in some CI environments), these lines will throw: https://github.com/vadimdemedes/ink/blob/master/src/components/App.js#L73 https://github.com/vadimdemedes/ink/blob/master/src/components/App.js#L83

This behaviour is detailed by the Node docs on https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode

When Node.js detects that it is being run with a text terminal (“TTY”) attached, process.stdin will, by default, be initialized as an instance of tty.ReadStream and both process.stdout and process.stderr will, by default be instances of tty.WriteStream. The preferred method of determining whether Node.js is being run within a TTY context is to check that the value of the process.stdout.isTTY property is true

After a search for setRawMode, it seems that this issue has resurfaced: https://github.com/vadimdemedes/ink/issues/40

While the easy fix would be to wrap all those calls with a check for stdin.isTTY, that might lead to unexpected behaviour when an app actually expects raw mode to have been set!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
eweilowcommented, Mar 21, 2019

@vadimdemedes What if <StdinContext> exposed an additional isRawModeSupported bool? It might lead to more 3rd party components adopting a nicer fallback if it was clear in the docs, even if it is currently as simple as checking if stdin.isTTY is true or not. Another option would be to simply add info on how to check for that in the docs of StdinContext 👍

0reactions
vadimdemedescommented, Mar 23, 2019

Nice, thanks @eweilow! Let’s continue discussion there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node daemon won't start with process.stdin.setRawMode(true)
I am running a node server daemon but I keep running into this error. When I run my bash strip to test the...
Read more >
non-tty console : WEB-1933 - JetBrains YouTrack
Write node.js script and run from "Command Line Tools Console": ... setRawMode()` instead. tty.js:37 throw new Error('can\'t set raw mode on non-tty'); ...
Read more >
Using stdout, stdin, and stderr in Node.js - LogRocket Blog
Running this application with node index.js would write the error message to our terminal similarly to how stdout would output it. It is...
Read more >
JavaScript terminal-menu示例- HotExamples
run -command.js'); var menu = Menu({ width: 40, x: 4, y: 2 }); menu.reset(); ... setRawMode(true); menu.on('close', function () { process.stdin.
Read more >
Code coverage report for node-npmtest-terminal-kit/node_modules ...
So we will try to maintain a fail-safe xterm generic config. term. ... be ignored: we are probably reading from a non-TTY }...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found