facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.31k stars 26.73k forks source link

Remove console clearing in logs (or at least allow to scroll) #611

Closed BenoitAverty closed 7 years ago

BenoitAverty commented 7 years ago

Hello,

I am a bit annoyed by the fact that create-react-app clears the console each time it compiles in 'npm start' logs.

For example, when I run npm start, I sometimes see that there's a warning but it disappears almost immediately and I can't read it. I can't even scroll up to see it!

It's also not very appropriate when I run both the client and server with node-foreman for example, because the app assumes it's the only one to run in the terminal.

Is there a way to disable this or a workaround ?

gaearon commented 7 years ago

when I run npm start, I sometimes see that there's a warning but it disappears almost immediately and I can't read it

We don't print any warnings that we clear afterwards. We actually care about only printing relevant information. If some tool we are using prints a stray warning, we should either surface it in a meaningful way, or completely silence it.

Can you comment out clearConsole() in node_modules/react-scripts/scripts/start.js and post a screenshot of that warning that was getting cleared?

It's also not very appropriate when I run both the client and server with node-foreman for example, because the app assumes it's the only one to run in the terminal

This is a bit of an advanced use case. I understand your point but the solution is not to completely disable clearing. It's to figure out how to do it well :wink: . Clearing is important because seeing outdated results from previous compilation is confusing to many people. It's hard to focus when your terminal output is full of errors that have already been resolved, but success message happens to be shorter than failure messages, so it is drowned in them.

We tried a few different escape sequences with different effects. The current one doesn't work well with scrolling. The previous one did not clear the screen initially on launch on Windows. I think we should change the code to use the current sequence on first call (so that Windows works well), but use the previous sequence for subsequent calls. Seems like that could solve both problems.

BenoitAverty commented 7 years ago

I'm perfectly fine with taking it slow and figuring out the best way to do it :)

Regarding the warning, it's actually foreman itself that does it, so there's actually nothing more to do besides figuring out the good way to clear the console.

This is a bit of an advanced use case.

I understand that it's a bit more advanced than the basic setup, but I think most people will want to have a backend at some point. And it quickly becomes annoying to have to start the app and the backend separately. I think a lot of people will look for a way to start both at the same time and hit this problem.

gaearon commented 7 years ago

I sort of feel that it should be up to Foreman to strip console clear sequences from the output. Since it attempts to merge outputs together, it makes sense that it should strip any escape sequences that cause conflicts between outputs.

gaearon commented 7 years ago

I expect https://github.com/facebookincubator/create-react-app/commit/801c20028fc8e53c4348f5d66eeb991a1e9e91f1 to fix it. At least, rather than clear the console completely, it should put a lot of lines between the last and next output.

If this still doesn’t quite work for you, I think you’ll need to bring it up with Foreman because it should be technically able to omit certain escape characters from the piped output.

gaearon commented 7 years ago

I’d appreciate if you could check if 0.4.2 works better.

BenoitAverty commented 7 years ago

Thanks for adding this. However, it doesn't work on my system (debian):

When using terminator or guake, I see a piece of the escape sequence on the screen. It inserts blank lines (like the "clear" command) but it inserts too many.

When using Hyperterm, It behaves exactly like before, almost as if the isFirstClear variable wasn't set.

On this screenshot, the top terminal is terminator and the bottom terminal is hyperterm.

I didn't test it on gnome-terminal, but Terminator is based on it so I expect it to behave similarly.

2016-09-19-093442_960x1023_escrotum

gaearon commented 7 years ago

I’d appreciate if you could try to fiddle with that sequence too. OS X and Windows are more of a focus for us, but if you could figure out something that works everywhere, that would be helpful.

BenoitAverty commented 7 years ago

Sure, I'll try to make some time and open a PR. I won't be able to test on MacOS though.

veqryn commented 7 years ago

I created a similar issue here: https://github.com/facebookincubator/create-react-app/issues/794 Essentially, we actually do not want any clearing of the console at all, so only clearing once (per 801c200), would not be sufficient. Clearing the console is a problem for anyone running this is in dev beside anything else (ie: using more than 1 docker container).

darthdeus commented 5 years ago

Is there no way to disable the clearing of the console altogether? I'm not using any complicated multi-process setup with foreman, though I'd still appreciate if it was under a flag, instead of just checking isInteractive. Especially if debugging a setup or just doing anything in the terminal it is quite annoying to have it cleared every time I start this.