tern: tern 0.24.1 - typing catch after ending try block causes crash

Tern version: 0.24.1

try {
  // code
} catch
  // ^^ typing catch here causes tern to crash
Exception in thread Request Completion:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/abe/.vim/bundle/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 321, in completation
    data = self.run_command(command, pos)
  File "/Users/abe/.vim/bundle/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 262, in run_command
    data = self.make_request(doc, silent)
  File "/Users/abe/.vim/bundle/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 230, in make_request
    req = opener.open(self._url, payload)
  File "/usr/local/Cellar/python/3.7.4/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.4/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.4/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.4/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.4/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.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1336, in getresponse
    response.begin()
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 275, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19

Most upvoted comments

I think I fixed this before but didn’t make a new release. And that might be the reason why I can’t reproduce.

Will release 0.24.2 today.

Hi,

I tested with tern 0.22 and works with no errors with 0.24 (I just updated) and the errors raises, here the error of tern. As I remember destructuring and async syntax causes some issues in new versions that is why I was using 0.22

Next some context that can help

Request: {
  "query": {
    "type": "completions",
    "types": true,
    "depths": true,
    "docs": true,
    "filter": true,
    "caseInsensitive": false,
    "guess": true,
    "sort": false,
    "expandWordForward": true,
    "omitObjectPrototype": false,
    "includeKeywords": true,
    "inLiteral": true,
    "file": "#0",
    "end": {
      "line": 22,
      "ch": 6
    },
    "lineCharPositions": true
  },
  "files": [
    {
      "type": "full",
      "name": "test.js",
      "text": "import { Controller } from 'stimulus';\nimport axios from 'axios';\n\nexport default class extends Controller {\n  static targets = [\n    'portfolioCompanies',\n  ];\n\n  async assignCategory(portfolioCompanyId, portfolioCategoryId) {\n    const url = `/portfolio-companies/${portfolioCompanyId}/categories`;\n\n    try {\n      const res = await axios.post(\n        url,\n        { porfolio_category_id: portfolioCategoryId },\n        {\n          headers: {\n            'Content-Type': 'application/json',\n            'X-CSRF-Token': document.querySelector('meta[name=csrf-token]').content,\n          },\n        },\n      );\n    } catch // catch - the moment you type catch the vim throws the error message above\n  }\n}"
    }
  ]
}
/usr/local/lib/node_modules/tern/lib/infer.js:1138
      if (node.param.type == "Identifier") {
                     ^

TypeError: Cannot read property 'type' of null
    at Object.CatchClause (/usr/local/lib/node_modules/tern/lib/infer.js:1138:22)
    at c (/usr/local/lib/node_modules/tern/node_modules/acorn-walk/dist/walk.js:58:37)
    at Object.base.TryStatement (/usr/local/lib/node_modules/tern/node_modules/acorn-walk/dist/walk.js:246:25)
    at c (/usr/local/lib/node_modules/tern/node_modules/acorn-walk/dist/walk.js:58:37)
    at Object.skipThrough (/usr/local/lib/node_modules/tern/node_modules/acorn-walk/dist/walk.js:186:39)
    at c (/usr/local/lib/node_modules/tern/node_modules/acorn-walk/dist/walk.js:58:37)
    at Object.base.Program.base.BlockStatement (/usr/local/lib/node_modules/tern/node_modules/acorn-walk/dist/walk.js:198:7)
    at Object.BlockStatement (/usr/local/lib/node_modules/tern/lib/infer.js:1134:17)
    at c (/usr/local/lib/node_modules/tern/node_modules/acorn-walk/dist/walk.js:58:37)
    at Object.skipThrough (/usr/local/lib/node_modules/tern/node_modules/acorn-walk/dist/walk.js:186:39)

Thanks, I will try create the same env to verify. (sorry just back from vacation)