carlitux / deoplete-ternjs

deoplete.nvim source for javascript
MIT License
277 stars 24 forks source link

try catch results in crash #77

Closed maccyber closed 5 years ago

maccyber commented 5 years ago

Writing following in neovim with this config

try {
} catch

Results in

Exception in thread Request Completion:                                                                                                                                                                                                                                          
Traceback (most recent call last):                                                                                                                                                                                                                                               
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner                                                                                                                                                                                                          
    self.run()                                                                                                                                                                                                                                                                   
  File "/usr/lib/python3.7/threading.py", line 865, in run                                                                                                                                                                                                                       
    self._target(*self._args, **self._kwargs)                                                                                                                                                                                                                                    
  File "/home/maccyber/.cache/vim/dein/repos/github.com/carlitux/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 318, in completation                                                                                                                          
    data = self.run_command(command, pos)                                                                                                                                                                                                                                        
  File "/home/maccyber/.cache/vim/dein/repos/github.com/carlitux/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 259, in run_command                                                                                                                           
    data = self.make_request(doc, silent)                                                                                                                                                                                                                                        
  File "/home/maccyber/.cache/vim/dein/repos/github.com/carlitux/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 227, in make_request                                                                                                                          
    req = opener.open(self._url, payload)                                                                                                                                                                                                                                        
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open                                                                                                                                                                                                                 
    response = self._open(req, data)                                                                                                                                                                                                                                             
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open                                                                                                                                                                                                                
    '_open', req)                                                                                                                                                                                                                                                                
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain                                                                                                                                                                                                          
    result = func(*args)                                                                                                                                                                                                                                                         
  File "/usr/lib/python3.7/urllib/request.py", line 1345, in http_open                                                                                                                                                                                                           
    return self.do_open(http.client.HTTPConnection, req)                                                                                                                                                                                                                         
  File "/usr/lib/python3.7/urllib/request.py", line 1320, in do_open                                                                                                                                                                                                             
    r = h.getresponse()                                                                                                                                                                                                                                                          
  File "/usr/lib/python3.7/http/client.py", line 1321, in getresponse                                                                                                                                                                                                            
    response.begin()                                                                                                                                                                                                                                                             
  File "/usr/lib/python3.7/http/client.py", line 296, in begin                                                                                                                                                                                                                   
    version, status, reason = self._read_status()                                                                                                                                                                                                                                
  File "/usr/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
carlitux commented 5 years ago

This is tern issue, maybe you are running latest that have some bugs.

maccyber commented 5 years ago

Ah, ok. Thanks!

abepark01 commented 5 years ago

Hi @maccyber!

I filed an issue at https://github.com/ternjs/tern/issues/1027, but they are saying that this is a deoplete-ternjs issue.

Tern: 0.24.1 Neovim: v0.4.2

I was able to reproduce the issue just now.

Here's a sample file that caused the crash (also found in the ticket above):

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
  }
}
abepark01 commented 5 years ago

@maccyber please disregard; the fix was made on the ternjs side. thank you!