jung-kim / atom-ungit

Atom plugin for Ungit project
MIT License
76 stars 12 forks source link

Uncaught TypeError: undefined is not a function #24

Open olmokramer opened 9 years ago

olmokramer commented 9 years ago

Reproduction Steps

  1. Trigger the ungit:toggle command from either the command palette or by running atom.commands.dispatch(atom.views.getView(atom.workspace), 'ungit:toggle') from the console

It says that activeItem.getUri on line 70 is undefined It points to the activeItem.getUri() function not being defined

Atom Version: 0.187.0 System: linux 3.19.1-towo.3-siduction-amd64 Thrown From: atom-ungit package, v0.4.2

Stack Trace

Uncaught TypeError: undefined is not a function

At /home/olmo/.atom/packages/atom-ungit/lib/atom-ungit.coffee:70

TypeError: undefined is not a function
  at Object.module.exports.toggle (/home/olmo/.atom/packages/atom-ungit/lib/atom-ungit.coffee:70:33)
  at atom-workspace.<anonymous> (/home/olmo/.atom/packages/atom-ungit/lib/atom-ungit.coffee:34:8)
  at atom-workspace.handler (/usr/share/atom/resources/app/src/space-pen-extensions.js:115:32)
  at atom-workspace.jQuery.event.dispatch (/usr/share/atom/resources/app/node_modules/space-pen/vendor/jquery.js:4681:9)
  at atom-workspace.elemData.handle (/usr/share/atom/resources/app/node_modules/space-pen/vendor/jquery.js:4359:46)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/src/command-registry.js:246:29)
  at /usr/share/atom/resources/app/src/command-registry.js:3:61
  at CommandPaletteView.module.exports.CommandPaletteView.confirmed (/usr/share/atom/resources/app/node_modules/command-palette/lib/command-palette-view.js:120:32)
  at CommandPaletteView.module.exports.SelectListView.confirmSelection (/usr/share/atom/resources/app/node_modules/atom-space-pen-views/lib/select-list-view.js:338:21)
  at space-pen-div.atom.commands.add.core:confirm (/usr/share/atom/resources/app/node_modules/atom-space-pen-views/lib/select-list-view.js:109:19)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/src/command-registry.js:246:29)
  at /usr/share/atom/resources/app/src/command-registry.js:3:61
  at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:558:16)
  at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:396:22)
  at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/usr/share/atom/resources/app/src/window-event-handler.js:182:20)

Commands

     -0:02.6 command-palette:toggle (atom-workspace.workspace.scrollbars-visible-always.block-cursor-block.dark-flat-ui-tab-syntax-background.theme-one-dark-syntax.theme-dark-flat-ui)
     -0:01.3 core:confirm (atom-text-editor.editor.mini)
     -0:01.3 ungit:toggle (atom-workspace.workspace.scrollbars-visible-always.block-cursor-block.dark-flat-ui-tab-syntax-background.theme-one-dark-syntax.theme-dark-flat-ui)

Config

{
  "core": {
    "disabledPackages": [
      "autocomplete",
      "preview",
      "wrap-guide",
      "build",
      "view-tail-large-files",
      "command-toolbar",
      "git-diff-popup",
      "ti-create",
      "ti-build-atom",
      "live-archive",
      "package-cop",
      "ti-alloy-related",
      "web-browser",
      "color-picker",
      "fancy-new-file",
      "markdown-preview",
      "travis-ci-status",
      "atom-browser-webview",
      "selection-outlines",
      "test-package",
      "atom-terminal-panel",
      "rubinius-terminal",
      "quantum-shell",
      "cursor-blink-interval",
      "less-compiler",
      "coffee-autocompile",
      "less-autocompile",
      "stylus-autocompile",
      "git-plus",
      "git-control"
    ],
    "themes": [
      "dark-flat-ui",
      "one-dark-syntax"
    ],
    "projectHome": "/home/olmo/projects",
    "audioBeep": false,
    "followSymlinks": true,
    "autoHideMenuBar": true
  }
}

Installed Packages

# User
Remote-FTP, v0.6.2
atom-alignment, v0.11.0
atom-color-highlight, v3.0.8
atom-handlebars, v0.4.0
atom-ternjs, v0.5.5
atom-ungit, v0.4.2
auto-host-markdown-image, v0.2.3
autocomplete-atom-api, v0.5.0
autocomplete-bibtex, v0.5.4
autocomplete-css, v0.4.0
autocomplete-html, v0.3.0
autocomplete-paths, v1.0.2
autocomplete-plus, v2.4.2
autocomplete-snippets, v1.0.1
autohide-tree-view, v0.15.5
bezier-curve-editor, v0.6.6
block-cursor, v0.10.1
bug-report, v0.6.3
caniuse, v0.5.3
change-case, v0.5.1
code-links, v0.3.8
dark-flat-ui, v1.1.2
docblockr, v0.6.3
file-icons, v1.5.1
fonts, v0.4.0
git-log, v0.3.0
git-tab-status, v1.5.3
hex, v0.5.0
highlight-selected, v0.9.1
html-entities, v0.3.1
http-status-codes, v1.0.3
indentation-indicator, v0.4.1
language-apache, v1.2.0
language-generic-config, v0.1.3
language-haml, v0.15.0
language-jade, v0.3.0
language-latex, v0.4.1
language-stylus, v0.1.0
linter, v0.12.0
linter-clang, v2.25.1
linter-coffeelint, v0.1.7
linter-cpplint, v0.1.3
linter-csslint, v0.0.11
linter-haml, v0.1.1
linter-htmlhint, v0.0.8
linter-javac, v0.1.3
linter-js-yaml, v1.0.0
linter-jshint, v0.1.0
linter-jsonlint, v0.1.2
linter-less, v0.3.1
linter-php, v0.0.11
linter-scss-lint, v0.0.14
linter-shellcheck, v0.0.7
linter-stylus, v0.1.0
linter-write-good, v0.2.2
linter-xmllint, v0.0.5
markdown-preview-plus, v1.3.0
markdown-scroll-sync, v0.3.2
mathjax-wrapper, v0.1.0
minimap, v4.6.0
minimap-bookmarks, v0.1.0
minimap-color-highlight, v4.1.0
minimap-find-and-replace, v4.2.0
minimap-git-diff, v4.1.2
minimap-highlight-selected, v4.2.0
minimap-selection, v4.2.0
npm-autocomplete, v0.1.1
permanent-delete, v0.1.2
preview-plus, v1.1.19
project-manager, v1.15.5
project-palette-finder, v2.4.16
read-only-indicator, v0.1.0
regex-railroad-diagram, v0.7.1
rest-client, v0.3.1
slash-closer, v0.7.1
symbols-tree-view, v0.6.1
sync-settings, v0.2.2
tabs-to-spaces, v0.8.1
terminal-panel, v1.10.0
texlicious, v0.3.9

# Dev
linter-stylus, v0.1.0
terminal-panel, v1.10.0
olmokramer commented 9 years ago

Ah this only happens when I'm not in a git project

jung-kim commented 9 years ago

Hmmm that is odd, it should have handled that fine. It might be due how we are handling no header set up. Will be looking into it.

jung-kim commented 9 years ago

So I'm very confused about this one. It is complaining at L70 and activeItem being null or undefined but it has a check for that in that same line.

I actually wasn't able to reproduce this as described, it worked for me to open atom-ungit on a repo that hasn't be initialized with git init. However I was able to reproduce this when I disable and re enabled atom-ungit with exact same error.

@olmokramer Did you do disable and reenable? Does this problem persist even after restarting atom after ungit installation?

olmokramer commented 9 years ago

I certainly didn't disable and enable the package again. But I think I didn't restart Atom after installing the package and trying it out. I'll see if I can get some reproducible steps.

olmokramer commented 9 years ago

Hey, I'm sorry I couldn't get back at you earlier. The check on L70 only checks if activeItem is truthy, but not if the function you're calling exists. So activeItem was truthy, but didn't have a property getUri. You can replace that line with:

if activeItem?.getUri?() is config.uri

This checks if activeItem isn't undefined or null, does the same for the function, if the function exists it executes it, and then it compares the result to config.uri

jung-kim commented 9 years ago

Thanks! I should have look into it more carefully...

ginus commented 9 years ago

Atom Version: 0.191.0 System: Unknown Windows Version Thrown From: atom-ungit package, v0.4.3

Stack Trace

Uncaught TypeError: undefined is not a function

At C:\Users\Administrator\.atom\packages\atom-ungit\lib\atom-ungit.coffee:92

TypeError: undefined is not a function
  at Socket.<anonymous> (C:\Users\Administrator\.atom\packages\atom-ungit\lib\atom-ungit.coffee:92:18)
  at emitOne (events.js:82:20)
  at Socket.emit (events.js:166:7)
  at readableAddChunk (_stream_readable.js:146:16)
  at Socket.Readable.push (_stream_readable.js:109:10)
  at Pipe.onread (net.js:517:20)

Commands

     -0:15.8 ungit:toggle (atom-text-editor.editor)

Config

{
  "core": {
    "disabledPackages": [
      "language-c",
      "language-clojure",
      "language-go",
      "language-ruby",
      "language-ruby-on-rails",
      "language-toml",
      "log-console",
      "language-objective-c",
      "language-mustache",
      "autocomplete",
      "jshint",
      "language-perl",
      "language-property-list",
      "emmet",
      "terminal-runner",
      "file-type-icons",
      "preview-plus",
      "atom-lint",
      "jslint",
      "atom-terminal-panel",
      "gitter",
      "tidy-tabs"
    ],
    "projectHome": "D:\\web",
    "themes": [
      "seti-ui",
      "monokai-seti"
    ]
  }
}

Installed Packages

# User
atom-ternjs, v0.5.19
atom-ungit, v0.4.3
autoclose-html, v0.15.0
autocomplete-paths, v1.0.2
autocomplete-plus, v2.10.0
autocomplete-snippets, v1.2.0
code-links, v0.3.8
coffee-links, v0.1.0
coffee-refactor, v0.6.2
color-picker, v1.6.0
git-go, v1.0.1
highlight-selected, v0.9.1
js-refactor, v0.3.0
language-asp, v1.0.0
language-aspx, v0.4.0
language-batchfile, v0.4.0
language-ect, v0.2.0
language-gitignore, v0.2.0
language-livescript-edge, v1.0.0
linter, v0.12.0
linter-coffeelint, v0.2.1
linter-csslint, v0.0.11
linter-htmlhint, v0.0.13
linter-jshint, v0.1.2
linter-lsc, v1.1.2
linter-php, v0.0.12
minimap, v4.7.6
mocha, v0.0.5
monokai-seti, v0.7.0
navigate, v0.0.10
project-palette-finder, v2.4.16
project-ring, v0.19.6
refactor, v0.4.1
rest-client, v0.3.1
seti-ui, v0.6.3
Stylus, v0.7.0
webbox-color, v0.5.6
zentabs, v0.8.4

# Dev
No dev packages
Lebawurscht commented 9 years ago

Atom Version: 0.202.0 System: WS2030W7 Thrown From: atom-ungit package, v0.4.3

Stack Trace

Uncaught TypeError: undefined is not a function

At C:\Users\th\.atom\packages\atom-ungit\lib\atom-ungit.coffee:92

TypeError: undefined is not a function
    at Socket.<anonymous> (C:\Users\th\.atom\packages\atom-ungit\lib\atom-ungit.coffee:109:21)
    at emitOne (events.js:82:20)
    at Socket.emit (events.js:166:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at Socket.Readable.push (_stream_readable.js:109:10)
    at Pipe.onread (net.js:517:20)

Commands

     -0:12.5.0 command-palette:toggle (atom-pane.pane.active)
     -0:09.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:08.9.0 ungit:toggle (atom-pane.pane.active)

Config

{
  "core": {
    "fileEncoding": "windows1252",
    "disabledPackages": [
      "tree-view",
      "metrics",
      "archive-view",
      "bookmarks",
      "welcome"
    ],
    "themes": [
      "atom-dark-ui",
      "monokai"
    ]
  }
}

Installed Packages

# User
atom-ungit, v0.4.3
hex, v0.6.2
highlight-selected, v0.9.3
language-batch, v0.3.3
language-ini, v1.10.0
language-pascal, v0.7.0
monokai, v0.14.0

# Dev
No dev packages