create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Console clearing removes CRA’s own warnings

Open denis-sokolov opened this issue 7 years ago • 20 comments

react-scripts start continuous scrollback clearing (#2495) clears the warnings CRA itself prints. Here is a visual demonstration slowed down:

blink

On a faster setup it is near impossible to read the warning before it disappears.

Platform: node 10.15.3, npm 6.9.0 Search terms: clear, console, warning, 2495.

Steps to Reproduce

  1. npx create-react-app my-app foo --typescript
  2. cd foo
  3. Delete allowSyntheticDefaultImports option in tsconfig.json
  4. npm start

Expected Behavior

Ideally react-scripts would not clear the scrollback (#2495) and let the user see the logs of what happened in the past. Given the resolution of that issue this is unlikely.

Alternatively, react-scripts should take a lot of care to not clear its own warnings.

denis-sokolov avatar Jun 17 '19 07:06 denis-sokolov

The warning message should probably be shown after the console clear.

bugzpodder avatar Jun 17 '19 09:06 bugzpodder

@denis-sokolov, would you like to raise a PR for this? As @bugzpodder we recognise that this could be improved.

mrmckeb avatar Jun 23 '19 13:06 mrmckeb

Unfortunately, I will not be making a PR to solve this, but I’m happy I brought this to your attention.

denis-sokolov avatar Jun 23 '19 16:06 denis-sokolov

Another option would be to make the clearing optional. I really would prefer that it not clear the console, as I'm usually running it in a docker container via docker-compose, and it clears the log for the whole constellation, so I can't see if other containers had startup issues.

hoylemd avatar Sep 04 '19 16:09 hoylemd

The fact that react-scripts has the audacity not to just clear screen, but clear the scrollback is mind-boggling.

As a workaround though for those of you using iTerm there is a way to disable this VT100 functionality. Thank you, thoughtful iTerm developers.

Screen Shot 2020-02-04 at 4 20 38 PM

Check the settings of your terminal emulator, there is a chance they have something similar.

NonLogicalDev avatar Feb 05 '20 00:02 NonLogicalDev

Console clear must be removed, it's so disruptive and unrespectful to the user to wipe all their previous terminal context which may even result in data loss in some cases.

I do currently workaround via npx react-scripts start | cat.

silverwind avatar Feb 07 '20 09:02 silverwind

+1 to making console clearing optional. This is really messing with my docker-compose workflow.

harrislapiroff avatar May 25 '20 02:05 harrislapiroff

Any progress on this? I have seen multiple issues and PR's (meaning there must be a need), but the only 'solution' so far is a work around which doesn't work on Windows machines. Thanks

thijsrausch avatar Jun 10 '20 16:06 thijsrausch

I've gone through #2495 and it's quite clear to see that the project maintainers are specifically attached to this user-hostile behavior of deleting their terminal scrollback data.

As well-evidenced in the discussion seen in another project, https://github.com/zloirock/core-js/issues/548, project maintainers are well within their rights to reject proposals, ignore complaints, and so on. Perhaps the only thing of consequence that you can count on is the record shown as a reflection on the maintainers' relationship with and attitude toward users, which shines through brilliantly here.

I am here because a project that I'm now working on exhibits this well-documented undesired behavior, and I came looking for a way to configure it not to erase my terminal scrollback. This is relatively benign behavior, all things considered. We would do well to recenter ourselves and consider how selfsame little recourse we might have if the behavior was actively malicious, deleting more than what is typically fairly disposable terminal scrollback content. I should not need to remind everyone that we're all working with code and it would not be difficult at all for any project's maintainers to embed, or even conceal code that can do real irreversible harm by forking a few simple processes. It's all built on trust. All this open source business.

That was a long-winded way of saying that this appalling attitude being shown to well-meaning would-be contributors to the project has already damaged the trust, beyond repair, of many potential users of the software. That much is clear. That is how I feel now and I cannot imagine that there are no others who feel the same. From now on it would be a point of principle that I never touch this software, promote it to anyone I work with (regardless of its true merit!), and I probably will even actively take measures to remove it from being a dev-dependency on the project that I currently work with.

I guess it comes down to kindness being rooted in thoughtfulness about the impact of your actions on others.

unphased avatar Jun 30 '20 19:06 unphased

This behavior is incredibly frustrating. I did not think it was possible for a software tool to be "audaciously unkind", but here is an excellent example. It's as if a browser extension implemented a "clear browser history" every time you loaded a page. Could you honestly imagine that being reasonably default behavior? Let alone behavior which is impossible to turn off?

Multiplexers don't even have a way implemented to turn off the scrollback-clear escape code, indicating that Jest's doing this is unprecedented across decades worth of TUI implementations.

There are two codes for clearing a terminal. \033[2J is reasonable to implement. But \E[3J? Why?

I have looked through the relevant issues here and I don't see a single justification from the team. Just the CRA maintainers closing any relevant issues with arbitrary reasons (feeding the command through a naked |cat is not a solution, as it ruins interactivity by unbinding the tty from stdin, which they built into the core of the program and so must know).

It may seem hyperbolic, but I think this is the most hostile ux design of a program I've seen that isn't intentional malware.

What's really irritating is that several PR's have been submitted which satisfy the preferences of the maintainers, yet they continue to deny them, saying there are valid workarounds. They then link to issues which show those workarounds, which are the workarounds which have bugs that the PR's they're commenting on specifically state they are trying to overcome with that PR.

If the maintainers want the default \033[2J + \E[3J behavior because they don't care about scrollback & prefer it nuked, fine, but what is the obstinate pushback against a toggleable environmental variable for the users for whom this is not preferred and is, to the contrary, very bad user experience? The code is already written.

The workarounds all involve piping through cat, which breaks stdin. So then CRA's suggested workaround is to neuter Jest's watcher facility?

Please leave the scrollback buffer alone. It isn't CRA's to nuke. Or at least merge-in one of the "everybody wins" PR's that are out there that do this with an environmental variable configuration. This is already a common pattern in CRA seen here.


EDIT: w/ links to the hostile-to-the-community issues I talked about

2017: PR which would make everyone happy No response, it gets approved and not merged. Then it gets closed without a response from the maintainers.

2017: link A maintainer says:

@drewswaycool @codepunkt @lmorchard @acusti @razzfox How do you feel about using concurrently as a workaround? ... which then draws a very clear answer from all participants of "no, this is not a valid workaround, but the suggested one would be" To which the maintainer then responds: Given that this issue is about providing a workaround to optionally not clear the console and several ways were provided to do so, I think we can finally resolve this issue. I don't see the need to further continuing this debate given the opinionated nature of CRA's defaults.

So why would CRA ask how the community feels about the workaround, if when they answer, CRA is going to say: "well too bad" and lock the issue? If CRA pleads with devs not to eject, and communicate what their challenges with the package are, why would they not just accept a PR like Use envar to disable clearConsole

2018-2019: 6102 With a lot of discussion, and the only thing said by a maintainer is:

This is done intentionally. We'll likely not merge this. Closed with: per #2495 (comment) several workarounds were provided for optionally not clearing the console. At this time, we will not consider adding an additional flag or changing the default within CRA. Thanks!

Which workarounds? What is linked is that original workaround, which was met with a chorus of "this is not a valid workaround".

Again, this could just be solved by merging one of the PR's such as 2495

dougpagani avatar Jul 03 '20 18:07 dougpagani

Clearing the current window/screen is fine. Clearing the terminal's scrollback buffer is VERY NOT OKAY.

Please leave the scrollback buffer alone. It isn't CRA's to nuke.

I can't reiterate that enough. The terminal's scrollback is not CRA's to erase. The reason I have a scrollback buffer is to scroll back and see things. The user's scrollback buffer belongs to the user, and clearing it without permission is claiming ownership of something CRA does not own, outside of its purview.

Refusing to provide an option to avoid clearing the scrollback, I just don't understand.

There needs to be an option to avoid clearing the scrollback. I don't know what else to say.

willxy avatar Jul 21 '20 03:07 willxy

Because CRA maintainers, after over 4 years of complaints, still refuse to provide a satisfying solution for preventing a user's scrollback buffer from getting nuked, I wrote-up a hack that will work with as much reliability & good UX as possible. The issue above has a copy-pasteable snippet, and as well, a write-up explaining what is going on.

It will only work for interactive situations, unfortunately. I will say again; the react maintainers have a responsibility (and an easy-to-fulfill one, at that) to implement a real solution; either with a --flag or $CONFIG_VAR.

dougpagani avatar Jul 21 '20 18:07 dougpagani

This is real pain for people implementing custom babel plugins in CRA. My code works fine on ASTexplorer but somehow it shows different output on CRA. I am sure it might be some silly mistake I am making in code but I can't debug this because terminal keeps clearing and I can't really proceed anywhere.

It would be really great if console clearing is made optional.

saurabhnemade avatar Jun 25 '21 01:06 saurabhnemade

+1

andrewchen5678 avatar Jul 02 '21 01:07 andrewchen5678

I noticed an unusual behavior of WebStorm IDE in-built terminal: it does not clear the scrollback despite create-react-app commanding to do so, which I see with a MasOS system terminal clearing the scrollback as described above. I thought this might be of help to someone.

@bugzpodder @mrmckeb Gentlemen, there is a PR for fixing this, as you requested. Do you think it might be the time to get back to this issue?

polyakoff avatar Aug 22 '21 10:08 polyakoff

Just think of it as a friendly exercise for developers to start using patch-package

vatosarmat avatar Oct 31 '21 04:10 vatosarmat

I wrote up an unobtrusive opt-in workaround for this in #11573 about 4 months ago, but have yet to have maintainer eyes on it.

forana avatar Apr 11 '22 13:04 forana

Mind-boggling hubris on the side of CRA maintainers. I didn't even know programs could wipe the scrollback buffer until your inconsequential script decided to hijack my terminal. Considering some people mostly work in the terminal, this superfluous action is akin to wiping the entire history in your fancy IDE. I'm sure you'd love to say goodbye to CTRL+Z every time you compile your app.

vultbot avatar Jun 22 '22 18:06 vultbot

this is wild - lots of other options for apps these days 🤷🏻‍♂️

berkeleymalagon avatar Mar 13 '23 23:03 berkeleymalagon

For a quick win, @silverwind's suggestion helped me to see an error presented by react-scripts start upon updating node ❤️ https://github.com/facebook/create-react-app/issues/7233#issuecomment-583316483

The hour I burnt discovering this nugget could well have been minimised had certain individuals found in #2495 & #6102 been more gracious, just look at all these folk trying to lend a hand, plus the support for the feature: https://github.com/facebook/create-react-app/pulls?q=is%3Apr+clearconsole

This https://github.com/facebook/create-react-app/issues/7233#issuecomment-502599793 is laughable after reading the aforementioned.

dpd73 avatar Apr 17 '23 11:04 dpd73