diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -171,7 +171,10 @@ class server(object):
         and writes the return code to the result channel """
 
         length = struct.unpack('>I', self._read(4))[0]
-        args = self._read(length).split('\0')
+        if not length:
+            args = []
+        else:
+            args = self._read(length).split('\0')
 
         # copy the ui so changes to it don't persist between requests
         req = dispatch.request(args, self.ui.copy(), self.repo, self.cin,