bracey.vim icon indicating copy to clipboard operation
bracey.vim copied to clipboard

TypeError: Cannot set property 'endIndex' of undefined

Open spro opened this issue 4 years ago • 2 comments

This error occasionally crashes the server while working on an HTML file. I haven't been able to pin down exactly what causes it, but seems like a sprinkle of try/catch would be helpful in the meantime.

~/.vim/bundle/bracey.vim/server/htmlfile.js:414
		elem.endIndex = this._parser.endIndex;
		              ^

TypeError: Cannot set property 'endIndex' of undefined
    at DomHandler.handler._setEnd (~/.vim/bundle/bracey.vim/server/htmlfile.js:414:17)
    at DomHandler.onElemEnd (~/.vim/bundle/bracey.vim/server/htmlfile.js:427:8)
    at Parser.onend (~/.vim/bundle/bracey.vim/server/node_modules/htmlparser2/lib/Parser.js:337:23)
    at Tokenizer._finish (~/.vim/bundle/bracey.vim/server/node_modules/htmlparser2/lib/Tokenizer.js:890:15)
    at Tokenizer.end (~/.vim/bundle/bracey.vim/server/node_modules/htmlparser2/lib/Tokenizer.js:881:29)
    at Parser.end (~/.vim/bundle/bracey.vim/server/node_modules/htmlparser2/lib/Parser.js:367:21)
    at parse (~/.vim/bundle/bracey.vim/server/htmlfile.js:432:9)
    at HtmlFile.setContent (~/.vim/bundle/bracey.vim/server/htmlfile.js:145:22)
    at Server.handleEditorCommand (~/.vim/bundle/bracey.vim/server/server.js:116:16)
    at Server.parseEditorRequest (~/.vim/bundle/bracey.vim/server/server.js:97:7)

spro avatar Dec 28 '20 08:12 spro

Thanks for reporting, I'll take a look when I get a chance. Any chance you could include the content of the HTML file when you ran into this issue?

turbio avatar Jan 03 '21 06:01 turbio

I don't have it anymore sorry, but I dug into the source and can confirm that wrapping the above statement with if(elem) fixed the issue for me.

spro avatar Jan 05 '21 00:01 spro