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: undefined is not a function #42

Closed

Description

@jakeharris

Full source visible here.

So far I've found it very hard to understand what is happening in Atom. As such, I've been looking at the packages other people have developed, as well as much of the Atom source. Most of the code in this example package is based on the code from postcasio in slash-closer.

In a new package's entry point, I do the following:

  1. Create a notification via atom.notifications.addSuccess('...', {}) to announce that Atom has loaded the package; this happens pre-module.exports
  2. In the activation function, create a notification via atom.notifications.addSuccess('...', {}) to announce that Atom has begun to run the activation code
  3. Later in the activation function, attempt to subscribe to changes in the editor buffer by creating a CompositeDisposable and adding the observeTextEditors Disposable to it (via atom.workspace.observeTextEditors(function (...) { ... })
  4. Within the observeTextEditors callback, start building particular subscriptions to the editor buffer, namely onDidChange and onDidDestroy.
  5. Within the onDidChange callback, create a notification via atom.notifications.addSuccess('...' {}) to announce that it noticed something changing in the editor.
  6. Ensure that Atom is aware of my package and reload. (The first two notifications are properly displayed.)
  7. Type something in any editor window.

Code in Question

Written in pure JS -- I find CoffeeScript very difficult to follow.

var CompositeDisposable = require('event-kit').CompositeDisposable,
    Helpers = require('./html-significant-other-helpers')


atom.notifications.addSuccess('significant-other loaded!', { dismissable: true })

module.exports = {

  activate: function (state) {
    atom.notifications.addSuccess('significant-other activated!', { dismissable: true })
    this.helpers = new Helpers
    this.subscriptions = new CompositeDisposable
    this.subscriptions.add(atom.workspace.observeTextEditors((function (_this) {
      return function(editor) {
        buffer = editor.getBuffer()

        var editorSubscriptions = new CompositeDisposable

        editorSubscriptions.add(buffer.onDidChange(function (e) {
          /* blows up right here */
          atom.notifications.addSuccess('significant-other entered editor subscription!', {dismissable: true})
          if (e.newText == '>') {
            if(this.helpers.isValidFileScope(editor)) {
              atom.notifications.addError('significant-other noticed we were in a valid file scope!', { dismissable: true })
              cursor = editor.getCursorBufferPosition()
              if (this.helpers.isValidBufferScope(cursor.getScopeDescriptor())) {

              }
            }
          }
        }))

        editorSubscriptions.add(buffer.onDidDestroy(function (e) {
          editorSubscriptions.dispose()
        }))

        _this.subscriptions.add(editorSubscriptions)
      };
    })(this)))
  },

Atom Version: 0.178.0
System: Mac OS X 10.10.2
Thrown From: notifications package, v0.27.0

Stack Trace

Uncaught TypeError: undefined is not a function

At /Applications/Atom.app/Contents/Resources/app/node_modules/notifications/lib/main.js:104

TypeError: undefined is not a function
  at Object.Notifications.addNotificationView (/Applications/Atom.app/Contents/Resources/app/node_modules/notifications/lib/main.js:104:24)
  at /Applications/Atom.app/Contents/Resources/app/node_modules/notifications/lib/main.js:30:24
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:82:11)
  at NotificationManager.module.exports.NotificationManager.addNotification (/Applications/Atom.app/Contents/Resources/app/src/notification-manager.js:54:20)
  at /Users/milieu/Projects/html-significant-other/lib/html-significant-other.js:20:30
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/service-hub/node_modules/event-kit/lib/emitter.js:82:11)
  at TextBuffer.module.exports.TextBuffer.applyPatch (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:594:20)
  at BufferPatch.module.exports.BufferPatch.applyTo (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/buffer-patch.js:74:21)
  at Transaction.module.exports.Transaction.applyTo (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/transaction.js:60:29)
  at History.module.exports.History.abortTransaction (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/history.js:165:24)
  at History.module.exports.History.transact (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/history.js:122:16)
  at TextBuffer.module.exports.TextBuffer.transact (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:687:27)
  at TextEditor.module.exports.TextEditor.transact (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:1195:26)
  at atom-text-editor.newCommandListeners.(anonymous function) (/Applications/Atom.app/Contents/Resources/app/src/text-editor-element.js:304:22)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:243:29)
  at __bind (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:61)
  at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:558:16)
  at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:396:22)
  at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:172:20)

Commands

     -3:11.2 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -3:11.2 core:cancel (atom-text-editor.editor.is-focused)
  5x -3:09.1 core:backspace (atom-text-editor.editor.is-focused)
  2x -3:05.5 core:move-left (atom-text-editor.editor.is-focused)
  2x -3:04.0 core:move-right (atom-text-editor.editor.is-focused)
     -3:02.9 core:move-left (atom-text-editor.editor.is-focused)
 21x -3:02.6 core:backspace (atom-text-editor.editor.is-focused)
  3x -2:59.8 core:save (atom-text-editor.editor.is-focused)
     -2:14.7 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -2:14.7 core:cancel (atom-text-editor.editor.is-focused)
  4x -2:13.5 core:backspace (atom-text-editor.editor.is-focused)
     -2:06.7 editor:move-to-end-of-screen-line (atom-text-editor.editor.is-focused)
  2x -2:06.5 core:move-left (atom-text-editor.editor.is-focused)
     -2:06.1 core:move-right (atom-text-editor.editor.is-focused)
  3x -2:02.1 core:save (atom-text-editor.editor.is-focused)
     -0:00.6 core:backspace (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "ignoredNames": [
      "...names related to an irrelevant project...",
      "*.css.map",
      "node_modules",
      ".sass-cache",
      ".git",
      ".DS_Store"
    ],
    "themes": [
      "yeti-ui",
      "yeti-syntax"
    ],
    "excludeVcsIgnoredPaths": false
  }
}

Installed Packages

# User
html-significant-other, v0.0.0
linter, v0.11.1
linter-clang, v2.25.1
yeti-syntax, v0.1.2
yeti-ui, v0.1.6

# Dev
No dev packages

Activity

  1. kevinsawicki commented on Apr 29, 2015

    @kevinsawicki
    Contributor

    Sorry for the delaying responding to this, are you still having this issue?

    I used the code you provided with the latest version of Atom but was unable to reproduce the issue.

  2. girishakj commented on May 26, 2015

    @girishakj

    Issue still exists!! I downloaded the latest AtomSetup.exe for Windows and whenever I open the editor, receiving the above error, any workaround?

  3. jakeharris commented on May 26, 2015

    @jakeharris
    Author

    I haven't been able to reproduce it in a bit either. I set Atom aside while I was working on other projects, came back, and...I don't know what changed, but I can no longer make this happen. Sorry I couldn't give you more information on this.

  4. Samcfuchs commented on May 31, 2015

    @Samcfuchs

    I am seeing this error when starting Atom. Just want to make clear that this is a continuing issue. It doesn't seem to affect anything else, though.

  5. jakeharris commented on Jun 1, 2015

    @jakeharris
    Author

    @Samcfuchs Could you submit what your installed packages are, stack trace, etc.? Increasing his awareness of its pervasiveness is important, but it doesn't help solve the problem.

  6. jamiecollinson commented on Jun 2, 2015

    @jamiecollinson

    Not sure if this helps diagnose but I'm getting the same error whenever I install the python-autocomplete package:

    https://github.com/sadovnychyi/autocomplete-python

    Stacktrace:
    Atom Version: 0.204.0
    System: Microsoft Windows 8.1 Pro
    Thrown From: notifications package, v0.50.0

    Stack Trace

    Uncaught TypeError: undefined is not a function

    At C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\node_modules\notifications\lib\notification-element.js:315
    
    TypeError: undefined is not a function
      at addSplitLinesToContainer (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\node_modules\notifications\lib\notification-element.js:315:20)
      at atom-notification.NotificationElement.render (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\node_modules\notifications\lib\notification-element.js:93:9)
      at atom-notification.NotificationElement.initialize (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\node_modules\notifications\lib\notification-element.js:50:33)
      at Object.createView (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\node_modules\notifications\lib\main.js:95:42)
      at ViewRegistry.module.exports.ViewRegistry.createView (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\src\view-registry.js:74:72)
      at ViewRegistry.module.exports.ViewRegistry.getView (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\src\view-registry.js:61:21)
      at Object.Notifications.addNotificationView (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\node_modules\notifications\lib\main.js:129:58)
      at C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\node_modules\notifications\lib\main.js:33:24
      at Emitter.module.exports.Emitter.emit (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\node_modules\event-kit\lib\emitter.js:82:11)
      at NotificationManager.module.exports.NotificationManager.addNotification (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\src\notification-manager.js:54:20)
      at NotificationManager.module.exports.NotificationManager.addWarning (C:\Users\jamie.collinson\AppData\Local\atom\app-0.204.0\resources\app.asar\src\notification-manager.js:37:19)
      at ChildProcess.<anonymous> (C:\Users\jamie.collinson\.atom\packages\autocomplete-python\lib\provider.coffee:53:28)
      at emitOne (events.js:77:13)
      at ChildProcess.emit (events.js:166:7)
      at Process.ChildProcess._handle.onexit (child_process.js:1055:12)
      at child_process.js:1127:20
      at process._tickCallback (node.js:357:13)
    
    

    Commands

         -5:04.7.0 vim-mode:move-to-line (atom-text-editor.editor.vim-mode.command-mode.is-focused)
         -5:03.9.0 vim-mode:move-down (atom-text-editor.editor.vim-mode.command-mode.is-focused)
     49x -5:03.4.0 vim-mode:move-up (atom-text-editor.editor.vim-mode.command-mode.is-focused)
      5x -5:01.3.0 vim-mode:move-down (atom-text-editor.editor.vim-mode.command-mode.is-focused)
      2x -5:00.4.0 vim-mode:move-up (atom-text-editor.editor.vim-mode.command-mode.is-focused)
      3x -4:59.4.0 vim-mode:move-right (atom-text-editor.editor.vim-mode.command-mode.is-focused)
      3x -4:58.7.0 vim-mode:move-left (atom-text-editor.editor.vim-mode.command-mode.is-focused)
         -4:57.4.0 vim-mode:change (atom-text-editor.editor.vim-mode.command-mode.is-focused)
         -4:57.1.0 vim-mode:select-inside-word (atom-text-editor.editor.vim-mode.is-focused.operator-pending-mode)
         -4:55.2.0 vim-mode:activate-command-mode (atom-text-editor.editor.vim-mode.is-focused.insert-mode)
         -4:54.5.0 vim-mode:undo (atom-text-editor.editor.vim-mode.is-focused.command-mode)
         -2:55.1.0 core:backspace (atom-text-editor.editor.mini.is-focused)
         -1:03.1.0 core:confirm (atom-text-editor.editor.mini.is-focused)
    

    Config

    {
      "core": {
        "themes": [
          "seti-ui",
          "seti-monokai"
        ],
        "audioBeep": false
      }
    }

    Installed Packages

    # User
    autocomplete-python, v0.4.1
    seti-monokai, v0.3.1
    seti-ui, v0.7.1
    vim-mode, v0.49.0
    
    # Dev
    No dev packages
  7. benogle commented on Jun 17, 2015

    @benogle
    Contributor

    @jamiecollinson your issue will be fixed in 0.210 which should be out today.

    We're now more defensive to guard against the original trace. If anyone else gets this error, please paste in your stack trace. You can use the copy button in the notification to copy the entire error report:

    copy-link

  8. Samcfuchs commented on Jun 20, 2015

    @Samcfuchs

    @javakat I have done a mass reinstall of packages, and I haven't gotten this error since. I hesitate to call it resolved, but I can't get a stack trace for it. Sorry for the delay.

  9. kevinsawicki commented on Jul 7, 2015

    @kevinsawicki
    Contributor

    I believe this was fixed by 3042481 and released available in Atom 1.0

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