tpope / vim-fireplace

fireplace.vim: Clojure REPL support
https://www.vim.org/scripts/script.php?script_id=4978
1.74k stars 139 forks source link

Omnicomplete Issues with Networking #337

Closed djblue closed 5 years ago

djblue commented 5 years ago

I recently started implementing a nrepl server for lumo, nrepl-cljs. I have been using vim-fireplace as my main nrepl client and have almost everything working except for auto complete. I do remember it working previously so I did a git bisect and determined that it worked before 4318be9. Upon reverting the commit, auto-complete worked unless the completion failed, however toggling the False to True seems to fix everything. I did confirm that nrepl has the same problem and fix.

diff --git a/python/nrepl_fireplace.py b/python/nrepl_fireplace.py
index 600eb60..4fc62fb 100644
--- a/python/nrepl_fireplace.py
+++ b/python/nrepl_fireplace.py
@@ -132,7 +132,7 @@ class Connection:
         return ''

     def receive(self, char=None):
-        f = self.socket.makefile('rb', False)
+        f = self.socket.makefile('rb', True)
         while len(select.select([f], [], [], 0.1)[0]) == 0:
             self.poll()
         try:

I'm not sure what's going on here as I don't know too much about python networking. Is the diff I provided the correct solution? Thanks.

tpope commented 5 years ago

Setting it to true causes it to buffer the read, which means extra data is read and discarded upon the f.close() below. The default changed from false to true in Python 3, so your change is essentially backporting a bug to all versions of Python.

djblue commented 5 years ago

Hi @tpope, thanks for responding so quickly. I don't want to backport a bug so I'll keep looking into it. Currently the main symptom I'm noticing is my tcp connection getting reset.

tpope commented 5 years ago

Coincidentally, I just found and fixed a different buffering bug, so you might have better results on the latest commit.

djblue commented 5 years ago

Updating to master fixes my issue, thanks!