ternjs/tern

tern 0.22.2/0.22.1 - Looks line tern was stopped or crashed. Delete .tern-port file and restart [n]vim

Closed this issue · 7 comments

It looks like the moment I press the dot operator tern crashes for version 0.22.2 and 0.22.1.
The issue does not occur in 0.21.

Running
node v8.12.0
npm 6.4.1
tern 0.22.1 and 0.22.2

Originally, it looked like there was an issue in the deoplete-ternjs but when I tried rolling back tern to 0.21 the issue went away.

I am running Python 3.7 locally.

Computer Info
MacOs High Sierra
Version 10.13.6
MacBook Air (13-inch, Mid 2013)
Processor 1.3 GHZ Intel Core i5
Memory 4 GB 1600 MHz DDR3

Exception in thread Request Completion:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/admin/.vim/bundle/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 318, in completation
    data = self.run_command(command, pos)
  File "/Users/admin/.vim/bundle/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 259, in run_command
    data = self.make_request(doc, silent)
  File "/Users/admin/.vim/bundle/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 227, in make_request
    req = opener.open(self._url, payload)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1345, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1320, in do_open
    r = h.getresponse()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 265, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

Any code snippets for this issue?
I think this is cause by new syntax.

@othree not sure if this will help, but here is the example that caused a crash for my own code.

import { Controller } from 'stimulus';

export default class extends Controller {
  static targets = [
    'form',
    'location',
  ];

  onLocationTextChange() {
    this.locationTarget.value = '';
    this.
    ^^^^crashes the moment I press dot
  }

  connect() {
    $('input[name="project[business_type_ids][]"]:hidden').attr('name', 'project_business_type_ids');
    this.validator = $(this.formTarget).validate({
      rules: {
        // validation rules
      },
      submitHandler: (form) => {
        $('input[name="project_business_type_ids"]:hidden').attr('name', 'project[business_type_ids][]');
        form.submit();
      },
    });
  }

  disconnect() {
    if (this.validator) {
      this.validator.destroy();
    }
  }
}

There also appears to be an example in the issue raised in carlitux/deoplete-ternjs#66

Thanks, found an issue is caused by anonymous class.

export default class extends Controller {

I will make a hotfix release for this.
You can try give the class a name and see is it work.

@othree for tern@0.22.2 I added a name for the class and autocomplete worked as expected.

Using anonymous classes with extend like below did work fine in tern@0.21.

export default class extends Controller {

Thank you for your help!

btw, acorn still not support class field.
so you will not get targets inside the class.

@othree yes, I noticed that autocomplete doesn't seem to work for static fields.

For example,

import React, { Component } from 'react';
import PropTypes from 'prop-types';

export default class NavMenu extends Component {
  static propTypes = {
    open: PropTypes.
                  ^^^ autocomplete results are not accurate.
  };

  render() {
  }
}

NavMenu.propTypes = {
  open: PropTypes.bool.isRequire,
                      ^^^ autocomplete results are accurate here
}