facebookarchive / nuclide

An open IDE for web and native mobile development, built on top of Atom
https://nuclide.io
Other
7.79k stars 682 forks source link

Opening a file from the console while atom is already running crashes nuclide #463

Closed despairblue closed 8 years ago

despairblue commented 8 years ago

[Enter steps to reproduce below:]

  1. atom-beta some_dir
  2. atom-beta some_file
  3. click somewhere in the file
  4. see lots of errors

Ignore the errors in the beginning. nuclide

Atom Version: 1.8.0-beta2 System: Mac OS X 10.11.3 Thrown From: nuclide package, v0.130.0

Stack Trace

Uncaught TypeError: Cannot read property 'null' of undefined

At /Users/danny/.atom/packages/nuclide/node_modules/react/lib/ReactMount.js:649

TypeError: Cannot read property 'null' of undefined
  at Object.ReactMount.findReactContainerForID (/Users/danny/.atom/packages/nuclide/node_modules/react/lib/ReactMount.js:649:50)
  at findParent (/Users/danny/.atom/packages/nuclide/node_modules/react/lib/ReactEventListener.js:41:30)
  at handleTopLevelWithoutPath (/Users/danny/.atom/packages/nuclide/node_modules/react/lib/ReactEventListener.js:87:16)
  at handleTopLevelImpl (/Users/danny/.atom/packages/nuclide/node_modules/react/lib/ReactEventListener.js:73:3)
  at ReactDefaultBatchingStrategyTransaction.Mixin.perform (/Users/danny/.atom/packages/nuclide/node_modules/react/lib/Transaction.js:136:20)
  at Object.ReactDefaultBatchingStrategy.batchedUpdates (/Users/danny/.atom/packages/nuclide/node_modules/react/lib/ReactDefaultBatchingStrategy.js:62:19)
  at Object.batchedUpdates (/Users/danny/.atom/packages/nuclide/node_modules/react/lib/ReactUpdates.js:94:20)
  at ReactEventListener.dispatchEvent (/Users/danny/.atom/packages/nuclide/node_modules/react/lib/ReactEventListener.js:204:20)

Commands

Config

{
  "core": {
    "autoHideMenuBar": true,
    "closeEmptyWindows": false,
    "customFileTypes": {
      "source.ini": [
        ".buckconfig",
        ".flowconfig"
      ],
      "source.json": [
        ".arcconfig"
      ],
      "source.python": [
        "BUCK"
      ]
    },
    "disabledPackages": [
      "atom-color-highlight",
      "atomatigit",
      "es-navigation",
      "filetype-color",
      "grunt-runner",
      "incremental-search",
      "linter-scspell",
      "markdown-scroll-sync",
      "metrics",
      "minimap-color-highlight",
      "minimap-find-and-replace",
      "minimap-git-diff",
      "minimap-highlight-selected",
      "minimap",
      "navigate",
      "tab-smart-sort",
      "Tern",
      "test-status",
      "themed-settings",
      "travis-ci-status",
      "tree-view-breadcrumb",
      "tree-view-open-files",
      "welcome",
      "nuclide-click-to-symbol",
      "nuclide-quick-open",
      "linter-jshint",
      "nuclide-file-tree",
      "nuclide-flow",
      "nuclide-file-tree-deux",
      "markdown-preview-opener",
      "nuclide-diagnostics-store",
      "nuclide-diagnostics-ui",
      "nuclide-debugger-node",
      "linter-htmlhint",
      "tree-view",
      "atom-pair",
      "Zen",
      "angularjs",
      "atom-zeal",
      "firepad",
      "language-tss",
      "lazy-motion",
      "open-plus",
      "swap-panes",
      "json-schema",
      "javascript-snippets",
      "linter-js-standard",
      "starred-package-installer",
      "linter-puppet-lint",
      "move-panes",
      "imdone-atom",
      "method-separator",
      "pane-layout-plus",
      "pane-move-plus",
      "git-blame",
      "gofmt",
      "autocomplete-go",
      "git-log",
      "go-get",
      "gometalinter-linter",
      "gorename",
      "language-haskell",
      "language-ocaml",
      "language-puppet",
      "navigator-godef",
      "tester-go",
      "grammar-token-limit",
      "block-travel",
      "atom-ternjs"
    ],
    "excludeVcsIgnoredPaths": false,
    "ignoredNames": [
      ".git",
      ".hg",
      ".svn",
      ".DS_Store",
      "._*",
      "Thumbs.db",
      "elm-stuff",
      "node_modules"
    ],
    "projectHome": "~/vcs/git/"
  },
  "nuclide": {
    "installRecommendedPackages": true,
    "lastConnectionDetails": {
      "config": {
        "authMethod": "PASSWORD",
        "cwd": "/Users/kietsy/git/kietsy",
        "host": "192.168.0.16",
        "pathToPrivateKey": "/home/despairblue/.ssh/id_rsa",
        "remoteServerCommand": "nuclide-start-server",
        "sshPort": "22",
        "username": "kietsy"
      },
      "lastOfficialRemoteServerCommand": "nuclide-start-server"
    },
    "nuclide-arcanist": {},
    "nuclide-buck-files": {},
    "nuclide-clang-atom": {},
    "nuclide-click-to-symbol": {
      "useCmdKey": false
    },
    "nuclide-datatip": {},
    "nuclide-debugger-hhvm": {},
    "nuclide-diagnostics-store": {
      "legacyLintOnTheFly": true
    },
    "nuclide-distraction-free-mode": {},
    "nuclide-file-tree": {
      "revealFileOnSwitch": true
    },
    "nuclide-flow": {
      "diagnosticsOnFly": true,
      "enableStructuredTypeHints": true
    },
    "nuclide-format-js": {},
    "nuclide-hack": {},
    "nuclide-health": {},
    "nuclide-home": {
      "showHome": false
    },
    "nuclide-ios-simulator-logs": {},
    "nuclide-ocaml": {},
    "nuclide-output": {},
    "nuclide-working-sets": {
      "workingSets": [
        {
          "name": "wunderflats",
          "active": false,
          "uris": [
            "/Users/danny/git/betterpayment",
            "/Users/danny/git/wunderflats-api",
            "/Users/danny/git/wunderflats-frontend",
            "/Users/kietsy/git/common",
            "/Users/kietsy/git/is24",
            "/Users/kietsy/git/is24-sync",
            "/Users/kietsy/git/wunderflats-api"
          ]
        },
        {
          "name": "elm",
          "active": false,
          "uris": [
            "/Users/kietsy/git/elm-go",
            "/home/despairblue/git/elm-oracle"
          ]
        },
        {
          "name": "jobs",
          "active": false,
          "uris": [
            "/Users/danny/git/betterpayment",
            "/Users/danny/git/common",
            "/Users/danny/git/configman",
            "/Users/danny/git/craigslist-sync",
            "/Users/danny/git/gunter",
            "/Users/danny/git/immoscout24sync",
            "/home/despairblue/git/job-gunter"
          ]
        }
      ]
    },
    "use": {
      "nuclide-arcanist": false,
      "nuclide-blame": false,
      "nuclide-blame-provider-hg": false,
      "nuclide-blame-ui": false,
      "nuclide-buck-files": false,
      "nuclide-buck-toolbar": false,
      "nuclide-clang-atom": false,
      "nuclide-clipboard-path": false,
      "nuclide-code-format": false,
      "nuclide-current-working-directory": false,
      "nuclide-debugger-hhvm": false,
      "nuclide-debugger-lldb-client": false,
      "nuclide-debugger-lldb-server": false,
      "nuclide-diff-view": false,
      "nuclide-format-js": false,
      "nuclide-hack": false,
      "nuclide-hack-symbol-provider": false,
      "nuclide-hg-repository": false,
      "nuclide-hhvm-toolbar": false,
      "nuclide-home": false,
      "nuclide-language-hack": false,
      "nuclide-remote-projects": false,
      "nuclide-test-runner": false
    }
  }
}

Installed Packages

# User
atom-alignment, v0.12.1
atom-spotify2, v2.1.2
atomic-chrome, v0.3.0
autocomplete-elixir, v1.5.13
autocomplete-emojis, v2.3.0
autocomplete-paths, v1.0.2
bug-report, v0.7.1
builder-go, v1.0.0
clipboard-plus, v0.5.1
color-picker, v2.1.1
compare-files, v0.6.2
docblockr, v0.7.3
editorconfig, v1.3.0
file-icons, v1.7.4
go-config, v1.1.4
go-plus, v4.1.0
haskell-grammar, v0.4.0
highlight-selected, v0.11.2
incsearch, v0.3.3
indentation-indicator, v0.6.0
language-babel, v2.17.3
language-docker, v1.1.6
language-dot, v1.6.0
language-elixir, v0.12.3
language-elm, v1.3.3
language-fish-shell, v1.0.3
language-ini, v1.16.0
language-latex, v0.6.1
language-nimrod, v0.1.0
language-thrift, v1.0.2
linter, v1.11.4
linter-coffeelint, v1.1.2
linter-elm-make, v0.4.0
linter-eslint, v7.2.0
linter-flow, v5.1.0
linter-js-standard-engine, v0.0.5
linter-js-yaml, v1.2.5
linter-shellcheck, v1.1.0
nix, v2.1.0
nuclide, v0.130.0
one-tab, v0.9.0
package-cop, v0.2.10
package-sync, v1.0.0
pdf-view, v0.50.0
pigments, v0.26.0
react, v0.15.0
regex-railroad-diagram, v0.16.0
standard-formatter, v2.0.0
symbols-tree-view, v0.12.0
tabs-to-spaces, v1.0.2
tool-bar, v0.4.0
vim-mode, v0.65.0
vim-mode-clipboard-plus, v0.2.0
vim-surround, v0.8.1
wakatime, v5.0.8

# Dev
No dev packages
johnislarry commented 8 years ago

My guess is that you have some conflicting package. I can't repro this on my machine and I only have Nuclide and vim-mode installed. When you open atom you get a lot of redboxes that seem to be about the linter, so maybe the issue is that the linter conflicts. I would try disabling the linter packages and other suspicious packages until the issue resolves, and then try to narrow the conflict down from there. I'll assign this to Nat and he can close it if he doesn't have anything else to add to my response.

despairblue commented 8 years ago

Oh, installing the linter package was the only way to get diagnostics to work after the last update (nuclide did not provide a linter anymore that could be consumed by the linters). Haven't reported that yet. I'll try to separate the issues and report any other tomorrow.

despairblue commented 8 years ago

@johnislarry I disabled all packages but nuclide and it's still happening. Are you sure you used the current atom-beta?

nuclide

ssorallen commented 8 years ago

@despairblue I'm able to reproduce this on Atom Beta v1.8.0-beta2. I will take a look.

ssorallen commented 8 years ago

@despairblue Can you see what the value of NODE_ENV is in your default environment? Try running NODE_ENV=production atom-beta. I can reproduce this if I run with no NODE_ENV set because it's letting React run in dev mode. I haven't tracked down what in React is breaking, but running in production mode seems to prevent this issue.

despairblue commented 8 years ago

NODE_ENV is not defined in my shell. Atom sets it to production on first start. So here's the culprit:

A new feature in Atom 1.8.0 is that atom overwrites the env vars when you start it from the shell with the ones that are present in the shell. What happens:

  1. You start atom and it sets sensible defaults
  2. You open another file from the shell and it overwrites those sensible defaults with whatever is set in your shell.

That's not a problem usually. Most of the time you actually want things like PATH to update.

In my opinion react should run in production mode unless NODE_ENV=development and not run in development mode unless NODE_ENV=production. It just seems too common that NODE_ENV is not set in an interactive shell. On the other hand: Why should react care about this specific use case? Most of the time it runs in a web browser where no one is overwriting process.env (which is probably set by webpack oder browserify).

Just for clarification, there seems to be a bug within react that produces theses errors, but fixing this is not fixing the underlying issue. Using atom from the command line while Atom is already open throws react in development mode (unless you export NODE_ENV=production), thus slowing down Atom as a whole. Not sure who's responsible for a fix in this case 😕

ssorallen commented 8 years ago

@despairblue One solution I've discussed with @zertosh is to ship Nuclide with the production/minified version of React that does not include the environment checks. Nuclide needs to eliminate 'react' as a top-level dependency, and then we can make the switch. The NODE_ENV will behave like apparently is desired in Atom v1.8, but it will no longer affect Nuclide's React.

despairblue commented 8 years ago

@ssorallen sounds like a plan! Any ETA on this?

zertosh commented 8 years ago

I took another look at this and I remembered the original problem with the minified version. It's react-dom and friends. But I think that if we use the dist version of react and react-dom loaded at the same time, we're ok. I have to test this. The other issue is with addons like the pure-render-mixin. We're going to end up with duplicate code loaded, but I think it's minimal.