tern 0.24.1 - typing catch after ending try block causes crash
Closed this issue ยท 19 comments
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
I can't reproduce this issue.
Can you provide more information?
How I test:
- Create base code:
try {
}
- type
catch
at bottom, which should produce:
try {
} catch
And I the tern server didn't crash. I also tried to trigger complete while typing. Also works.
@othree I was able to just reproduce the crash
I am using async/await here.
import { Controller } from 'stimulus';
import axios from 'axios';
export default class extends Controller {
static targets = [
'portfolioCompanies',
];
async assignCategory(portfolioCompanyId, portfolioCategoryId) {
const url = `/portfolio-companies/${portfolioCompanyId}/categories`;
try {
const res = await axios.post(
url,
{ porfolio_category_id: portfolioCategoryId },
{
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': document.querySelector('meta[name=csrf-token]').content,
},
},
);
} catch // typing catch triggers a crash
}
}
I still can't reproduce this. What editor are you using?
Your code in previous edit will cause tern crash because it don't have {
. But current edit don't crash tern.
@othree
I am using neovim 0.38 with the plugins deoplete-ternjs and deoplete.vim
Your code in previous edit will cause tern crash because it don't have
{
. But current edit don't crash tern.
No, the issue is that the moment I type in the keyword catch
it crashes... so, it doesn't let me fill in the {
Here is the stack trace.
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 _bootstr
ap_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 ope
n
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 _op
en
'_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 _ca
ll_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 ht
tp_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 getre
sponse
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
import { Controller } from 'stimulus';
import axios from 'axios';
export default class extends Controller {
static targets = [
'portfolioCompanies',
];
async assignCategory(portfolioCompanyId, portfolioCategoryId) {
const url = `/portfolio-companies/${portfolioCompanyId}/categories`;
try {
const res = await axios.post(
url,
{ porfolio_category_id: portfolioCategoryId },
{
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': document.querySelector('meta[name=csrf-token]').content,
},
},
);
} // catch - the moment you type catch the vim throws the error message above
}
}
@othree
Here are a couple more settings in my .vimrc
file.
let g:tern#command = ['tern']
let g:tern#arguments = ["--persistent"]
Thanks, I will try create the same env to verify. (sorry just back from vacation)
Looks like this is an deoplete-ternjs issue.
I did reproduce this bug.
But my tern server did not get any request while the exception occurs.
Please open issue at https://github.com/carlitux/deoplete-ternjs
Thanks @othree
I found an existing ticket (closed) at carlitux/deoplete-ternjs#77 and added a comment there.
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)
@carlitux Hi, thanks
This issue is related to the acorn upgrade.
I will try to figure out how to deal with it.
And I might need to know how to debug deoplete-ternjs.
I saw some self.debug
such as: https://github.com/carlitux/deoplete-ternjs/blob/307f9c3beb178026d122d9ab3825e4640dd1c29a/rplugin/python3/deoplete/sources/ternjs.py#L219
But don't know where to see the logs.
Could you provide some suggestion?
@othree I think the simplest way for you is:
- open a terminal at root project and run
tern --verbose
- open vim with deoplete and deoplete-ternjs and start editing.
To try again you have to close and open again vim as deoplete-ternjs
is disable when an error is raised this to avoid annoying user.
Thanks for quick response :)
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.
@abepark01 0.24.2 release. Please take a try.
it is working for me