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

Uncaught TypeError: Cannot read property 'length' of null #29

Closed
yongkangchen opened this issue Sep 10, 2014 · 7 comments
Closed

Uncaught TypeError: Cannot read property 'length' of null #29

yongkangchen opened this issue Sep 10, 2014 · 7 comments

Comments

@yongkangchen
Copy link

Uncaught TypeError: Cannot read property 'length' of null /Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/history.js:100

mac os x: 10.9.4
atom: 0.125.0

Also, I try to debug and print the error stack:

TypeError
 "TypeError: Cannot read property 'length' of null
  at Marker.module.exports.Marker.resumeChangeEvents (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/marker.js:558:47)
  at MarkerManager.module.exports.MarkerManager.resumeChangeEvents (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/marker-manager.js:235:30)
  at TextBuffer.module.exports.TextBuffer.applyPatch (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:448:15)
  at TextBuffer.module.exports.TextBuffer.setTextInRange (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:322:12)
  at Editor.module.exports.Editor.setIndentationForBufferRow (/Applications/Atom.app/Contents/Resources/app/src/editor.js:1033:26)
  at LanguageMode.module.exports.LanguageMode.autoDecreaseIndentForBufferRow (/Applications/Atom.app/Contents/Resources/app/src/language-mode.js:394:28)
  at Editor._results.push._this.(anonymous function) [as autoDecreaseIndentForBufferRow] (/Applications/Atom.app/Contents/Resources/app/node_modules/delegato/lib/delegator.js:67:61)
  at Selection.module.exports.Selection.insertText (/Applications/Atom.app/Contents/Resources/app/src/selection.js:478:21)
  at /Applications/Atom.app/Contents/Resources/app/src/editor.js:807:31
  at /Applications/Atom.app/Contents/Resources/app/src/editor.js:502:27
  at History.module.exports.History.transact (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/history.js:90:18)
  at TextBuffer.module.exports.TextBuffer.transact (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1020:27)
  at Editor.module.exports.Editor.transact (/Applications/Atom.app/Contents/Resources/app/src/editor.js:1104:26)
  at Editor.module.exports.Editor.mutateSelectedText (/Applications/Atom.app/Contents/Resources/app/src/editor.js:495:19)
  at Editor.module.exports.Editor.insertText (/Applications/Atom.app/Contents/Resources/app/src/editor.js:804:21)
  at Editor.object.(anonymous function) [as insertText] (/Applications/Atom.app/Contents/Resources/app/node_modules/underscore-plus/lib/underscore-plus.js:55:27)
  at [object Object].module.exports.React.createClass.onTextInput (/Applications/Atom.app/Contents/Resources/app/src/editor-component.js:870:18)
  at HTMLDivElement.boundMethod (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1295:21)

This is how to reproduce the bug:
bug

@izuzak
Copy link

izuzak commented Sep 10, 2014

@yongkangchen Can you reproduce this in safe mode?

@yongkangchen
Copy link
Author

safe mode is normal. I guess this cause by autocomplete-plus, and I create the same issue.

@izuzak
Copy link

izuzak commented Sep 10, 2014

Thanks for confirming. I'm going to close this issue, but please reopen it in https://github.com/atom/atom if you notice it in safe mode.

Also, I'm going to cc @nathansobo and @benogle on this -- that stack trace above is interesting, it doesn't seem to include anything related to autocomplete-plus, so I'm wondering if there indeed is something we could do to prevent these exceptions.

@izuzak izuzak closed this as completed Sep 10, 2014
yongkangchen referenced this issue Sep 10, 2014
Since we’re deprecating emissary, I manually implemented event pausing
to keep the event-kit library simpler.
@izuzak
Copy link

izuzak commented Sep 10, 2014

Reopening, see 94115e2#commitcomment-7727788

@izuzak izuzak reopened this Sep 10, 2014
@zenizh
Copy link

zenizh commented Sep 10, 2014

Exactly the same problem here on OS X 10.9.4 and Atom 0.125.0.
And I also use autocomplete-plus.
Just for reference.

@yongkangchen
Copy link
Author

@kami30k I temporary edit the file /Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/marker.js and modify function resumeChangeEvents to avoid the annoying bug, and you can try it until they fix this.

    Marker.prototype.resumeChangeEvents = function() {
      var deferredChangeEvents, event, _i, _len, _results;
      deferredChangeEvents = this.deferredChangeEvents;
      this.deferredChangeEvents = null;
      _results = [];

      if(deferredChangeEvents){
        for (_i = 0, _len = deferredChangeEvents.length; _i < _len; _i++) {
          event = deferredChangeEvents[_i];
          this.emit('changed', event);
          _results.push(this.emitter.emit('did-change', event));
        }
      }
      return _results;
    };

@nathansobo
Copy link
Contributor

This must be happening when something is inserting a marker within a buffer change event callback. Certainly a valid use case but it wasn't exercised by any of our code. This should be fixed on the next release, which we will expedite. Thanks for your patience.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants