-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request failed: (nil) in Emacs #605
Comments
Who knows what that means, but without it, we get byte soup when reading a non-ascii response. Issue #605
I can't reproduce the error message you get ('Request failed: (nil)'), but if I put some cyrillic text into a buffer, I get other errors. I've fixed those in the attached patch. Could you try whether it works for you? If not, could you give me the exact file you are using, and make sure you're on the current version of Tern? |
Thank you for reply! I tried your solution, but got same result - 'Request failed: (nil)'. What I did:
After that, I tried to understand what was going on and found that the error occurs during parsing JSON request in /bin/tern (line 220). I insert a bit logging and look that comes to the server. As you can see that at the end of the string with cyrillic missing curly bracket and JSON.pase method throws exception. I do not understand what could be the cause of this error. And about second question, I'm not quite sure what file I need to give you? |
I tried to use plugin for gedit and it works fine with cyrillic. So I can assume that the problem is hidden in tern.el. |
Interesting. If I follow those steps, I get string-based completions now. Are you on Linux? If so, what is your Have you tried starting your own Tern server and looking at what it does? (Go to the directory where your file is, maybe |
Yes, I am on Linux, Ubuntu 14.03. Yes, I tried starting my own Tern server with --verbose command line argument and --port argument with value from .tern-port. So my Emacs connects with started Tern server and I get output from screenshot above (in my previous comment) - Response: 400 JSON parse error: Unexpected end of input. This occurs because the missing curly brace at the end of JSON request (JSON.parse in /bin/tern line 220). I checked that no other Tern server running (via ps aux | grep node). |
I think I see what you mean. Looks like Emacs' HTTP request is somehow cut off, probably by some multibyte-character-related bug. The question then, is why my emacs isn't doing the same thing. Might be an emacs 25 bug (I'm using 24.5.1). Do you still have an emacs 24 on your system? Can you try with that? |
(Also, to test the byte-length vs character-length bug theory, did you test whether more characters are missing from the JSON when there are more multibyte characters in the request?) |
Sorry for my english... I checked with Emacs 24.5.1 and all works fine. So, I can conclude that this is a bug in Emacs 25. |
Okay. If you want to submit a bug with the emacs people (this is probably very easy to reproduce outside of Tern), that would probably be the best way to get this addressed. |
The main difference in |
Okay, so then the lack of encoding in the JSON layer is triggering another issue in the way we send the request (or in the way the url library handles it). @dgutov Do you know enough about emacs to debug why the server would be receiving truncated bodies when it is sent non-ascii data? |
Not truncated, apparently. This fixes it for me: diff -u /home/gutov/.emacs.d/backups/\!home\!gutov\!.emacs.d\!elpa\!tern-20150818.317\!tern.el.\~1\~ /home/gutov/.emacs.d/elpa/tern-20150818.317/tern.el
--- /home/gutov/.emacs.d/backups/!home!gutov!.emacs.d!elpa!tern-20150818.317!tern.el.~1~ 2015-08-21 13:00:23.717642400 +0300
+++ /home/gutov/.emacs.d/elpa/tern-20150818.317/tern.el 2015-08-21 13:15:48.157667156 +0300
@@ -26,7 +26,7 @@
(let* ((url-mime-charset-string nil) ; Suppress huge, useless header
(url-request-method "POST")
(deactivate-mark nil) ; Prevents json-encode from interfering with shift-selection-mode
- (url-request-data (json-encode doc))
+ (url-request-data (encode-coding-string (json-encode doc) 'utf-8))
(url-show-status nil)
(url (url-parse-make-urlobj "http" nil nil tern-server port "/" nil nil nil)))
(url-http url #'tern-req-finished (list c))))
Diff finished. Fri Aug 21 13:17:13 2015 |
Thanks, that looks sensible. Attached patch includes it. |
Thanks. Although if |
Thank you very much! |
Hello,
I tried to use tern in emacs and got message "Request failed: (nil)" when edit file which contains non english characters.
For example,
but if editable file contains only english characters then all works fine
In what can be a reason?
Emacs: GNU Emacs 25.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8) of 2015-05-19 on lcy01-07
OS: Linux Mint 17.2 Cinnamon
P.S. Sorry for my english, I used Google Translate...
The text was updated successfully, but these errors were encountered: