ponyup icon indicating copy to clipboard operation
ponyup copied to clipboard

"show" command timeout doesn't work

Open superherointj opened this issue 4 years ago • 17 comments

Currently "ponyup show ponyc" blocks if ponyc is not already installed. As an user, I was expecting it to return the channel versions available. It only stops blocking after downloading some version of application, would be nice if it listed all version channels available for application (before downloading) instead.

To reproduce blocking behavior, try deleting the ~/.local/shared/ponyup/ folder.

superherointj avatar Jan 05 '20 22:01 superherointj

@superherointj I'm unable to reproduce this.

It does what I would expect. It exits after displaying nothing.

SeanTAllen avatar Jan 05 '20 22:01 SeanTAllen

Right. I'll close this.

superherointj avatar Jan 05 '20 22:01 superherointj

@superherointj rather than closing, I'd rather investigate why it hangs for you. Perhaps I misunderstand "blocks". I assume you mean that it hangs and never returns a result, is that not what you meant?

SeanTAllen avatar Jan 05 '20 22:01 SeanTAllen

I've made several attempts here some failed some succeed. My current hypothesis is a network problem to reach some ponyup server. But it did not return anything it would just block and never return a result, the application would not return to bash prompt. And I kept wondering what was happening. My internet is normal ponyup service/server is the exception.

Currently I can still reproduce the blocking behavior, as long as I try several times the command "ponyup show ponyc". No feedback is given to user on failure.

Once I saw: "error: server unreachable, please try again later" but I am not able to repeat this error now because I'm not sure if it happened with same comand above, probably happened with a different command.

superherointj avatar Jan 05 '20 23:01 superherointj

I don't believe show makes a network connection. AFAIK, it only checks the local .lock file. @Theodus can you confirm that?

SeanTAllen avatar Jan 05 '20 23:01 SeanTAllen

I would be incorrect, by default, it does indeed make a network call.

SeanTAllen avatar Jan 05 '20 23:01 SeanTAllen

@Theodus The documentation is "The ponyup show command will display the installed package versions" which says to me that it shouldn't need to make a network call. It appears there is some confusion between what the code is doing and the documentation.

Can you clarify what is going on?

SeanTAllen avatar Jan 05 '20 23:01 SeanTAllen

"netstat -ctp" connection log when blocking:

  Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
  tcp        0      1 x220-arch:54408         server-99-84-27-2:https FIN_WAIT1   2593/ponyup         

x220-arch is my hostname. And then it waits forever.

superherointj avatar Jan 05 '20 23:01 superherointj

@superherointj does it time out after about 5 seconds?

SeanTAllen avatar Jan 05 '20 23:01 SeanTAllen

I see no output in console or any timeout. On netstat, it says the connection is FIN_WAIT1. The application never ends execution and is blocked forever (it seems).

A user on stack overflow said: FIN_WAIT1 => The application on local machine has closed the connection. Indication of this has been sent to the remote machine.

Suggested reference: https://www.freesoft.org/CIE/Course/Section4/11.htm

superherointj avatar Jan 05 '20 23:01 superherointj

There's a timeout of 5 seconds on the network call, so that isn't working correctly.

SeanTAllen avatar Jan 05 '20 23:01 SeanTAllen

It makes a network call to mark packages that are not the latest versions. "If a more recent version is not installed, then the more recent version will be shown in yellow following the selected version."

Theodus avatar Jan 05 '20 23:01 Theodus

Alright, so I'm going to change this to "timeout doesn't work".

SeanTAllen avatar Jan 05 '20 23:01 SeanTAllen

I have the same behaviour as @superherointj on linux. ponyup show is hang for 2min10s before timing out on my computer. Here is strace output when it is blocked in case it helps:

$ sudo strace -p 26447
strace: Process 26447 attached
futex(0x7f902ad4ef60, FUTEX_WAIT_PRIVATE, 1, NULL) = 0
munmap(0x7f902a54c000, 8400896)         = 0
munmap(0x7f9021d49000, 8400896)         = 0
ioctl(0, SNDCTL_TMR_CONTINUE or TCSETSF, {B38400 opost isig icanon echo ...}) = 0
exit_group(0)                           = ?
+++ exited with 0 +++

pmetras avatar Dec 23 '21 01:12 pmetras

And the problem is not limited to the show command:

$ time ponyup update corral release
updating corral-release-latest-x86_64-linux
syncing updates from https://api.cloudsmith.io/packages/ponylang/releases/
pulling corral-release-0.5.4-x86_64-linux
  |██████████████████████████████████████████████████| corral-release-0.5.4-x86_64-linux.tar.gz
selecting corral-release-0.5.4-x86_64-linux as default for corral
 bin: /home/pierre/.local/share/ponyup/corral-release-0.5.4-x86_64-linux/bin/corral
link: /home/pierre/.local/share/ponyup/bin/corral

real	2m9,497s
user	0m0,042s
sys	0m0,000s

From what I've briefly looked at the source, the timeout seems to be set only for the show command. Writing down to the link line takes less than 1 second but then it hangs. Seems more like client and server are not closing correctly the TCP session like @superherointj pointed out.

pmetras avatar Dec 23 '21 02:12 pmetras

This was discussed in the sync call.

Sean says there are two issues with this probably:

:one: it seems the timeouts are not being set correctly in all cases - this should be easier to fix

:two: a much more subtle/rare bug in some user's network setup, which is going to be harder to reproduce and fix.

@redvers has seen this before on his machine with buggy IPv6 from his ISP. He is going to reproduce and see if he can help.

jemc avatar Jan 04 '22 19:01 jemc

I confirm the problem with IPv6. My ISP decided to stop providing IPv6 over IPv4 for the type of modem I have last year, but my modem kept a IPv6 address without me noticing. I think that situation created that the IPv6 request failed with timeout before the stack sent a new request with IPv4.

Now everything's fine for me and ponyup show ponyc answers in 1 s.

pmetras avatar Feb 24 '22 02:02 pmetras