This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Uncaught TypeError: undefined is not a function #42
Copy link
Copy link
Closed
Description
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:
- Create a notification via atom.notifications.addSuccess('...', {}) to announce that Atom has loaded the package; this happens pre-module.exports
- In the activation function, create a notification via atom.notifications.addSuccess('...', {}) to announce that Atom has begun to run the activation code
- 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 (...) { ... })
- Within the observeTextEditors callback, start building particular subscriptions to the editor buffer, namely onDidChange and onDidDestroy.
- Within the onDidChange callback, create a notification via atom.notifications.addSuccess('...' {}) to announce that it noticed something changing in the editor.
- Ensure that Atom is aware of my package and reload. (The first two notifications are properly displayed.)
- 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
kevinsawicki commentedon Apr 29, 2015
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.
girishakj commentedon May 26, 2015
Issue still exists!! I downloaded the latest AtomSetup.exe for Windows and whenever I open the editor, receiving the above error, any workaround?
jakeharris commentedon May 26, 2015
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.
Samcfuchs commentedon May 31, 2015
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.
jakeharris commentedon Jun 1, 2015
@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.
jamiecollinson commentedon Jun 2, 2015
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
Commands
Config
{ "core": { "themes": [ "seti-ui", "seti-monokai" ], "audioBeep": false } }Installed Packages
Be defensive when adding a notification view
benogle commentedon Jun 17, 2015
@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:
Samcfuchs commentedon Jun 20, 2015
@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.
kevinsawicki commentedon Jul 7, 2015
I believe this was fixed by 3042481 and released available in Atom 1.0