-
Notifications
You must be signed in to change notification settings - Fork 326
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
Possible race condition when using remote commands at startup #495
Comments
@SPFabGerman I have taken a look at this now. I can reproduce the issue as early as r14. I think you are right that it is related to server not being ready when a remote command is run. It is possible to get rid of this issue by starting the server manually beforehand, maybe from within a desktop launch script or so. There has also been some recent changes with the server behavior. Remote command errors are now shown as output. So alternatively you can use the following to try the command until success (currently this should only work in master):
I have also replaced
We could also move this logic to the remote commands to try commands until success with increasing intervals but I'm not sure if this is always desirable. I'm inclined to think that the current first method is good enough for now. |
I think having error messages on stderr and returning a non-zero exit status is the best solution for this problem. That could be integreated very well in various shell scripts, etc.. Maybe it would be a good idea to have kind of a |
@SPFabGerman I have taken a look at the code now. It seems that non-zero return code should already be the case when the server is not ready. So the following example should already work:
But it doesn't work. The reason is that when the server is not ready, client keeps trying to connecting with increasing intervals. If this remote command arrives before the client connects to the server but after the server starts running, command is silently dropped since there is no client connection exists on the server to send the command. I will try to add an error message for this case. Returning a non-zero code for such errors on the server side is more complicated and I don't have an easy way to do it yet. I'm still not sure if it is a good idea to assume any returned message should be considered an error. I'm not sure how a |
Maybe it's related or a separate issue. I ended up with a command as a such:
Occasionally, but steady the execution is failed on the second remote command and it's only selected a file on ui. Note, I run lf binary from the lfcd.sh from the documentation. |
@iDanko This issue is about commands at startup so I don't think your issue is related. By the way, I don't remember |
When starting lf, it ignores sometimes remote commands that are in the rc file.
E.g. when I have something like
$lf -remote "send $id echo TEST"
in my lfrc file, the TEST is only displayed around half the time.It is possible to somewhat work around that, by using something like this:
&sleep 1; lf -remote "send $id echo TEST"
, but this will still not have a guaranteed success.This is especially problematic, when setting up mappings using remote commands, since the mapping will simply not be available.
This looks like a race condition with the server startup to me.
So sometimes the server is not ready to accept remote commands and so the command is simply dropped.
I tested a bit more and found, that the ´lf -remote ...´ command exits without any errors, even if the command was dropped.
This issue was not always present, since on an earlier version of lf (r14, if I remember correctly) everything worked fine.
The text was updated successfully, but these errors were encountered: