zed icon indicating copy to clipboard operation
zed copied to clipboard

Generic socket listening/accepting on Zed service port causes hang

Open philrz opened this issue 2 years ago • 0 comments

Repro is with Zed commit 88f40ed and was uncovered during a PR review for a docs update.

Start this simple program that listens on a socket, accepts an incoming connection, and does no more.

$ cat mysocket.py 
#!/usr/local/bin/python3
import socket
import sys

if (len(sys.argv) != 2 or not sys.argv[1].isdigit()):
  print('Usage: listen <port>')
  exit()

p = int(sys.argv[1])
l = []
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', p))
s.listen(1)
while 1:
  (c, a) = s.accept()
  l.append(c)
  print('%d: connection from %s' % (len(l), a))

$ python3 mysocket.py 9867

At this point if I run a command like zed ls, it seems the logic for locating the lake gets to the step 3 listed there and hangs forever.

When I described this to @nwt, he responded that it's a bug. Not sure what he had in mind (e.g., more of an app-level check that it's actual Zed API endpoint that's listening, and/or maybe a timeout?) but I'm open to improvements!

philrz avatar Oct 25 '23 20:10 philrz