sindresorhus / atom-editorconfig

Helps developers maintain consistent coding styles between different editors
https://atom.io/packages/editorconfig
MIT License
812 stars 80 forks source link

Uncaught TypeError: Cannot read property 'reduce' of undefined #219

Closed vtambourine closed 5 years ago

vtambourine commented 6 years ago

[Enter steps to reproduce:]

  1. Open any file in the project tree.
  2. Execute "EditorConfig: Show State" command from the command palette.

Expected: Editor config status shown. Result: Error appeared.

Atom: 1.26.0 x64 Electron: 1.7.11 OS: Mac OS X 10.12.6 Thrown From: editorconfig package 2.2.2

Stack Trace

Uncaught TypeError: Cannot read property 'reduce' of undefined

At /Users/vtambourine/.atom/packages/editorconfig/commands/show.js:5

TypeError: Cannot read property 'reduce' of undefined
    at notificationTemplate (/packages/editorconfig/commands/show.js:5:17)
    at HTMLElement.init (/packages/editorconfig/commands/show.js:55:17)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:384:49)
    at Object.didConfirmSelection (/Applications/Atom.app/Contents/Resources/app/node_modules/command-palette/lib/command-palette-view.js:152:35)
    at SelectListView.confirmSelection (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-select-list/src/select-list-view.js:401:26)
    at HTMLDivElement.core:confirm (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-select-list/src/select-list-view.js:106:20)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:384:49)
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
    at WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:110:40)

Commands

  3x -3:35.4.0 core:close (input.hidden-input)
     -1:11.6.0 nuclide-file-tree:reveal-active-file (input.hidden-input)
  2x -0:43.9.0 core:close (input.hidden-input)
     -0:16.4.0 command-palette:toggle (input.hidden-input)
  3x -0:12 core:move-down (input.hidden-input)
     -0:11.3.0 core:move-up (input.hidden-input)
     -0:11.1.0 core:confirm (input.hidden-input)
     -0:11.1.0 EditorConfig:show-state (input.hidden-input)

Non-Core Packages

aligner 1.2.4 
aligner-javascript 1.3.0 
aligner-ruby 1.6.1 
editor-stats 0.17.0 
editorconfig 2.2.2 
highlight-selected 0.13.1 
language-crystal-actual 0.37.2 
language-docker 1.1.8 
language-perl-html-template 2.1.0 
language-riot-tag 0.2.2 
minimap 4.29.8 
minimap-bookmarks 0.4.2 
minimap-highlight-selected 4.6.1 
nuclide 0.291.0 
proto-repl 1.4.22 
riot 0.4.1 
dennisgaebel commented 5 years ago

This still occurs with Atom 1.35.1 running on Mojave OS

Alhadis commented 5 years ago

@dennisgaebel Are you using Nuclide as well?

dennisgaebel commented 5 years ago

@Alhadis Nope. What else can I provide to help remedy this bug?

Alhadis commented 5 years ago

Stack traces, a list of non-core packages you have installed, and what packages you purposefully disabled (if any). Similar to what @vtambourine provided in the OP.

Nuclide uses a very different set of UI components for Atom's workspace, replacing elements such as the file-tree with a more sophisticated project-browser, as well as other non-trivial replacements. These are the sorts of things that would naturally cause compatibility issues with certain packages assuming the existence of a tree-view pane...

dennisgaebel commented 5 years ago

@Alhadis Here are those deets. There is no Core packages that have been disabled on my end.

Stack Trace

Uncaught TypeError: Cannot read property 'reduce' of undefined

/Users/grayghost/.atom/packages/editorconfig/commands/show.js:6

TypeError: Cannot read property 'reduce' of undefined
    at notificationTemplate (/Users/grayghost/.atom/packages/editorconfig/commands/show.js:6:17)
    at HTMLElement.init (/Users/grayghost/.atom/packages/editorconfig/commands/show.js:56:17)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:350017)
    at Object.didConfirmSelection (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:677438)
    at SelectListView.confirmSelection (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:840539)
    at HTMLDivElement.core:confirm (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:835418)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:350017)
    at KeymapManager.t.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1212981)
    at KeymapManager.t.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1209115)
    at WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:285196)

Non-Core Community Packages

├── atom-html-preview@0.2.6
├── atom-solarized-dark-ui@0.28.1
├── autoclose-html@0.23.0
├── bezier-curve-editor@0.7.2
├── caniuse@1.0.0
├── color-picker@2.3.0
├── editorconfig@2.3.0
├── emmet@2.4.3
├── git-time-machine@2.1.0
├── language-liquid@0.7.0
├── livestyle-atom@0.2.10 (disabled)
├── project-plus@1.0.0
├── split-diff@1.6.0
└── teletype@0.13.3
Alhadis commented 5 years ago

Gonna give this a thorough test and clean up. The exact error which was reported in the OP has so far been unreproducible, but the immediate fix is self-explanatory (check if value is null-ish before attempting to access a property or method).

Already patched it locally, will push as soon as I've finished trying to recreate the error...

Alhadis commented 5 years ago

Still couldn't reproduce the exact stack trace, but at this point, I'm pretty damn sure it's no longer an issue...

Figure 1

Figure 2 Figure 3

dennisgaebel commented 5 years ago

@Alhadis Thanks for the fix! 👍 🍻