Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Uncaught TypeError: Cannot read property 'nodeName' of undefined #85

Closed

Description

@dudupeters

[Enter steps to reproduce below:]

  1. Click on Language or Encoding in status bar.
  2. That's it.

Atom Version: 1.0.0-2cf5523
System: Debian GNU/Linux
Thrown From: notifications package, v0.56.0

Stack Trace

Uncaught TypeError: Cannot read property 'nodeName' of undefined

At /usr/share/atom/resources/app.asar/node_modules/notifications/lib/command-logger.js:81

TypeError: Cannot read property 'nodeName' of undefined
    at CommandLogger.module.exports.CommandLogger.logCommand (/usr/share/atom/resources/app.asar/node_modules/notifications/lib/command-logger.js:81:38)
    at /usr/share/atom/resources/app.asar/node_modules/notifications/lib/command-logger.js:33:24
    at Emitter.module.exports.Emitter.emit (/usr/share/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app.asar/src/command-registry.js:235:20)
    at CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app.asar/src/command-registry.js:3:61)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (/usr/share/atom/resources/app.asar/src/command-registry.js:163:19)
    at encoding-selector-status.<anonymous> (/usr/share/atom/resources/app.asar/node_modules/encoding-selector/lib/encoding-status-view.js:40:25)

Commands

Config

{
  "core": {
    "projectHome": "/home/peters/work/"
  }
}

Installed Packages

# User
No installed packages

# Dev
No dev packages

Activity

  1. ricardopieper commented on Jul 19, 2015

    @ricardopieper

    I'm having the same issue on Atom 1.0.2 - edd8ecc (built by @yuki-takei that solve #6306)
    When I try to put it in fullscreen or saving a file or when I click on the encoding setting on the status bar, i get the same exception.

    I have haskell-language, haskell-ide, haskell-ghc-mod and some themes.
    The saving action doesn't throw any exceptions if I try to save any file, except when it's a Haskell (.hs) source.

  2. ricardopieper commented on Jul 19, 2015

    @ricardopieper

    I got some more information. I don't know the atom infrastructure, but doesn't seem like a bug in this package. Seems like Atom has a problem.

    In my case, I had the @yuki-takei's version which solves atom/atom#6306, then I tried to do that by myself, inspiring (copying) the code from Yuki.
    Then I forked the main atom repo and applied the same code that Yuki did. However, the problem continued. I suppose it happens because Yuki and me are using a newer version of Electron (instead of the old atom shell), in my case, 0.29.3, and Chrome 43 doesn't know how to handle Object.create event where typeof event is CustomEvent. Yuki tried to copy the properties from one object to another, but it didn't solve it completely.

    This description looks like a soap opera, but still.

    An 'event' object was still required, and the notifications package wasn't receiving it.

    What I did to solve was to explicitly pass another object on command-registry.coffee, in the function @handleCommandEvent, where the obejct syntheticEvent is constructed, so the object looks like this:

    syntheticEvent = Object.create {},
      eventPhase: value: Event.BUBBLING_PHASE
      currentTarget: get: -> currentTarget
      target: value: currentTarget
      preventDefault: value: ->
        originalEvent.preventDefault()
      stopPropagation: value: ->
        originalEvent.stopPropagation()
        propagationStopped = true
      stopImmediatePropagation: value: ->
        originalEvent.stopImmediatePropagation()
        propagationStopped = true
        immediatePropagationStopped = true
      abortKeyBinding: value: ->
        originalEvent.abortKeyBinding?()
    
    #taken from https://github.com/yuki-takei/atom-using-electron-chrome-42/tree/edd8eec11d605ee77459232a010c1ac8a3a1ec42
    for k, v of originalEvent when k not in syntheticEvent
      syntheticEvent[k] = v
    

    After adding this target: value: currentTarget, everything worked fine, as far as I know.

  3. winstliu commented on Feb 11, 2016

    @winstliu
    Contributor

    @ricardopieper Can you still reproduce this on Atom 1.5.1?

  4. despairblue commented on Apr 6, 2016

    @despairblue

    I get the same notification linking to here, though I think the underlying cause might be different. This happens whenever I switch from a buffer with unsaved changes to another buffer. I used break on uncaught exception to get the stacktrace:

    TypeError: Cannot read property 'getLastCursor' of undefined
      at /Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/status-bar/lib/cursor-position-view.js:60:53
      at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
      at Emitter.module.exports.Emitter.emit (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
      at TextEditor.module.exports.TextEditor.cursorMoved (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/text-editor.js:1732:27)
      at Selection.module.exports.Selection.markerDidChange (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/selection.js:926:21)
      at /Applications/Atom Beta.app/Contents/Resources/app.asar/src/selection.js:41:24
      at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
      at Emitter.module.exports.Emitter.emit (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
      at TextEditorMarker.module.exports.TextEditorMarker.notifyObservers (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/text-editor-marker.js:264:27)
      at /Applications/Atom Beta.app/Contents/Resources/app.asar/src/text-editor-marker.js:65:26
      at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
      at Emitter.module.exports.Emitter.emit (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
      at Marker.module.exports.Marker.emitChangeEvent (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/marker.js:396:20)
      at /Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/marker-layer.js:288:27
      at Set.forEach (native)
      at MarkerLayer.module.exports.MarkerLayer.emitChangeEvents (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/marker-layer.js:284:46)
      at TextBuffer.module.exports.TextBuffer.emitMarkerChangeEvents (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1335:34)
      at TextBuffer.module.exports.TextBuffer.transact (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:852:12)
      at /Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/whitespace/lib/whitespace.js:52:25
      at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
      at Emitter.module.exports.Emitter.emit (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
      at TextBuffer.module.exports.TextBuffer.saveAs (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1082:20)
      at TextBuffer.module.exports.TextBuffer.save (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1074:19)
      at TextEditor.module.exports.TextEditor.save (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/text-editor.js:660:26)
      at Pane.module.exports.Pane.saveItem (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/pane.js:717:18)
      at Object.module.exports.autosavePaneItem (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/autosave/lib/autosave.js:58:21)
      at /Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/autosave/lib/autosave.js:23:26
      at atom-pane.PaneElement.activeItemChanged (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/pane-element.js:152:25)
      at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
      at Emitter.module.exports.Emitter.emit (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
      at Pane.module.exports.Pane.setActiveItem (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/pane.js:282:22)
      at Pane.module.exports.Pane.activateItemAtIndex (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/pane.js:414:19)
      at Pane.module.exports.Pane.activatePreviousItem (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/pane.js:379:21)
      at atom-workspace.commandRegistry.add.pane:show-previous-item (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/register-default-commands.js:23:48)
      at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/command-registry.js:260:29)
      at /Applications/Atom Beta.app/Contents/Resources/app.asar/src/command-registry.js:3:61
      at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:580:16)
      at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom Beta.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:388:22)
      at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/window-event-handler.js:98:36)
      at HTMLDocument.<anonymous> (/Applications/Atom Beta.app/Contents/Resources/app.asar/src/window-event-handler.js:3:61)

    Command History

         -3:35.3 blur (ol.results-view.list-tree.focusable-panel.has-collapsable-children)
      2x -3:32.9 vim-mode:move-up (atom-text-editor.editor.vim-mode.insert-mode.hyperclick)
         -3:32.0 vim-mode:insert-after-end-of-line (atom-text-editor.editor.vim-mode.insert-mode.hyperclick)
         -3:30.9 pane:show-previous-item (atom-text-editor.editor.vim-mode.insert-mode.hyperclick)
      2x -0:04.5 blur (atom-text-editor.editor.vim-mode.insert-mode.hyperclick)
         -0:03.4 core:cancel (ol.results-view.list-tree.focusable-panel.has-collapsable-children)
         -0:02.4 command-palette:toggle (ol.results-view.list-tree.focusable-panel.has-collapsable-children)
         -0:02.3 blur (ol.results-view.list-tree.focusable-panel.has-collapsable-children)
         -0:02.0 command-palette:toggle (atom-text-editor.editor.mini)
         -0:02.0 blur (atom-text-editor.editor.mini)
         -0:01.6 command-palette:toggle (ol.results-view.list-tree.focusable-panel.has-collapsable-children)
         -0:01.5 blur (ol.results-view.list-tree.focusable-panel.has-collapsable-children)
         -0:00.0 core:confirm (atom-text-editor.editor.mini)
         -0:00.0 blur (atom-text-editor.editor.mini)
         -0:00.0 bug-report:open (ol.results-view.list-tree.focusable-panel.has-collapsable-children)
    

    Versions

    • Atom: 1.7.0-beta4
    • Atom-Shell:
    • OS: Mac OS X 10.11.3
    • Misc
      • Could not determine apm version information

    This report was created in and posted from the Atom editor using the package bug-report v0.7.1.

  5. despairblue commented on Nov 30, 2016

    @despairblue

    This happens when a buffer is saved without having the focus. How to reproduce:

    1. Enable auto-save
    2. Open a file (one that is already saved to the hard drive)
    3. Edit it
    4. Pres Cmd+, w/o saving it
  6. Ben3eeE commented on Nov 30, 2016

    @Ben3eeE

    @despairblue your issue sounds like a duplicate of atom/status-bar#146 which has been fixed for a long time. Consider updating Atom to the latest version.

  7. despairblue commented on Nov 30, 2016

    @despairblue

    @Ben3eeE I believe I'm uptodate:

    • Atom: 1.12.6
    • Atom-Shell:
    • OS: Mac OS X 10.12.1
    • Misc
      • apm 1.12.9
      • npm 3.10.5
      • node 4.4.5
      • python 2.7.10
      • git 2.10.2
  8. despairblue commented on Nov 30, 2016

    @despairblue

    @Ben3eeE my comment from April probably was the error you linked to. Now I'm also getting a stack trace that is similar to the one the OP has:

    TypeError: Cannot read property 'nodeName' of undefined
      at CommandLogger.module.exports.CommandLogger.logCommand (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/notifications/lib/command-logger.js:81:38)
      at /Applications/Atom.app/Contents/Resources/app.asar/node_modules/notifications/lib/command-logger.js:33:24
      at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
      at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
      at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:240:20)
      at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:59)
      at CommandRegistry.module.exports.CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:160:19)
      at enterNormalMode (/Users/despairblue/Dropbox/dotfiles/Atom/.atom/init.coffee:60:17)
      at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
      at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
      at TextBuffer.module.exports.TextBuffer.saveAs (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1154:27)
      at TextBuffer.module.exports.TextBuffer.save (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1124:19)
      at TextEditor.module.exports.TextEditor.save (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:871:26)
      at Pane.module.exports.Pane.saveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:738:18)
      at Pane.saveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:3:59)
      at Object.autosavePaneItem (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/autosave/lib/autosave.js:58:21)
      at /Applications/Atom.app/Contents/Resources/app.asar/node_modules/autosave/lib/autosave.js:23:26
      at atom-pane.PaneElement.activeItemChanged (/Applications/Atom.app/Contents/Resources/app.asar/src/pane-element.js:152:25)
      at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
      at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
      at Pane.module.exports.Pane.setActiveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:288:22)
      at Pane.module.exports.Pane.activateItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:437:21)
      at /Applications/Atom.app/Contents/Resources/app.asar/src/workspace.js:545:18
    

    I also tried to fiddle with the whitespace package. It does not seem to be part of this issue here, the error is thrown no matter what configs I choose or even if I disable it.

    Also it it does not happen if I simply click another window to trigger the autosave. So I believe it's connected to save being run while the buffer is hidden.

  9. despairblue commented on Nov 30, 2016

    @despairblue

    The stack from where the Error is thrown:

    Error
      at eval (<anonymous>:1:2)
      at Pane.module.exports.Pane.handleSaveError (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:1030:9)
      at Pane.module.exports.Pane.saveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:746:25)
      at Pane.saveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:3:59)
      at Object.autosavePaneItem (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/autosave/lib/autosave.js:58:21)
      at /Applications/Atom.app/Contents/Resources/app.asar/node_modules/autosave/lib/autosave.js:23:26
      at atom-pane.PaneElement.activeItemChanged (/Applications/Atom.app/Contents/Resources/app.asar/src/pane-element.js:152:25)
      at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
      at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
      at Pane.module.exports.Pane.setActiveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:288:22)
      at Pane.module.exports.Pane.activateItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:437:21)
      at /Applications/Atom.app/Contents/Resources/app.asar/src/workspace.js:545:18
    
    
  10. Ben3eeE commented on Nov 30, 2016

    @Ben3eeE

    @despairblue can you try in safe mode atom --safe and see if it still happens?

  11. despairblue commented on Nov 30, 2016

    @despairblue

    Nevermind me, I had this in my init.coffee:

    # Enter normal mode on save
    enterNormalMode = () ->
      # when execution ends up here, there is no active TextEditor anymore...
      editorElement = atom.views.getView(atom.workspace.getActiveTextEditor())
      atom.commands.dispatch(editorElement, 'vim-mode:activate-normal-mode')
    
    atom.workspace.observeTextEditors (editor) ->
      editor.getBuffer().onDidSave enterNormalMode

    fixed it by replacing it with

    # Enter normal mode on save
    enterNormalMode = (editor) -> () ->
      editorElement = atom.views.getView(editor)
      atom.commands.dispatch(editorElement, 'vim-mode:activate-normal-mode')
    
    atom.workspace.observeTextEditors (editor) ->
      editor.getBuffer().onDidSave (enterNormalMode editor)

    @Ben3eeE thank you and sorry for taking you time :)

  12. Ben3eeE commented on Nov 30, 2016

    @Ben3eeE

    Going to close this out since it looks like it was solved by upgrading Electron version. If anyone is still having this problem then please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions