Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running `atom` from the command line can un-set `process.env.NODE_DEV`, causing performance degradation & JS crashes #12024

Closed
ggreer opened this issue Jun 22, 2016 · 3 comments

Comments

@ggreer
Copy link
Contributor

commented Jun 22, 2016

Unless Atom is running in dev mode, it sets process.env.NODE_ENV to "production". (The relevant code is here:

process.env.NODE_ENV ?= 'production' unless devMode
) This improves the speed of React by disabling its debug mode.

But if Atom is already running, and already has file.txt open, and one runs atom file.txt from the command line, the command line's environment is used to overwrite Atom's current process.env. Most people don't have NODE_DEV set in their environment, so React falls back to its slow debug mode.

The code responsible for "cloning" the environment is

delete to[key]
Notice that it deletes the existing environment.

If React starts in production mode, it won't create some key debugging data structures. If it later changes to dev mode (because process.env.NODE_DEV becomes undefined), it will try to access those structures and crash.

This bug is responsible for several reported issues in packages that I maintain: Floobits/atom-term3#63
Floobits/floobits-atom#121

@50Wliu

This comment has been minimized.

Copy link
Member

commented Jun 22, 2016

/cc @lee-dohm

@ggreer

This comment has been minimized.

Copy link
Contributor Author

commented Jun 22, 2016

Just FYI, I'll probably make a PR for this today.

ggreer added a commit to Floobits/atom that referenced this issue Jun 22, 2016

Don't erase NODE_ENV from environment. Atom sets this to 'production'…
… earlier, but some code paths can cause it to be un-set. This degrades performance and sometimes crashes React. Fixes atom#12024.

ggreer added a commit to Floobits/atom that referenced this issue Jun 23, 2016

Don't erase NODE_ENV from environment. Atom sets this to 'production'…
… earlier, but some code paths can cause it to be un-set. This degrades performance and sometimes crashes React. Fixes atom#12024.
@lock

This comment has been minimized.

Copy link

commented Apr 6, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

@lock lock bot locked and limited conversation to collaborators Apr 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants
You can’t perform that action at this time.