Skip to content
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

Infinite loop downloading files if connection is lost #285

Closed
bill-long opened this issue May 18, 2015 · 3 comments
Closed

Infinite loop downloading files if connection is lost #285

bill-long opened this issue May 18, 2015 · 3 comments

Comments

@bill-long
Copy link

Starting on line 110 in Get-WebFile.ps1, there is a loop that reads from the stream:

do
{
   $count = $reader.Read($buffer, 0, $buffer.Length);
...
} while ($count -gt 0)

If the first Read() succeeds, $count will contain a value greater than 0. However, if Read() then starts throwing exceptions due to loss of connection, $count will not be updated and the loop will be repeated forever. This results in the following error, over and over again:

 Exception calling "Read" with "3" argument(s): "Unable to read data from the tr
 ansport connection: Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstel
 le nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die herges
 tellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat."
 At C:\ProgramData\chocolatey\helpers\functions\Get-WebFile.ps1:112 char:8
 +        $count = $reader.Read($buffer, 0, $buffer.Length);
 +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
     + FullyQualifiedErrorId : IOException

Simplest fix is probably just:

do
{
   $count = 0
   $count = $reader.Read($buffer, 0, $buffer.Length);
...
} while ($count -gt 0)

Edit: On second thought, that would break out of the loop but it would also make it appear that Get-WebFile succeeded. This should probably be a fatal error.

@ferventcoder ferventcoder added this to the 0.9.9.7 milestone May 18, 2015
@ferventcoder ferventcoder modified the milestones: 0.9.9.7, 0.9.9.8 Jun 5, 2015
@ferventcoder ferventcoder modified the milestones: 0.9.9.8, 0.9.9.9 Jun 26, 2015
@ferventcoder
Copy link
Member

This was seen filling up someone's drive at https://chocolatey.org/packages/poweriso#comment-2110611483

@GillesJ
Copy link

GillesJ commented Jul 14, 2015

This issue caused two .zip installation files to fill my drive: one was 90GB (for the Eclipse package) and another of 15GB. My internet connection is wonky and often cuts out, so it's probably due to this loss of connection bug.

@ferventcoder ferventcoder self-assigned this Jul 25, 2015
ferventcoder added a commit that referenced this issue Jul 25, 2015
Previously, if the network connection is lost in the middle of
downloading a file, it will cause an infinite loop of error messages
similar to

~~~
Exception calling "Read" with "3" argument(s): "Unable to read data
from the transport connection:
~~~

Another unwelcome side effect is that the (corrupted) download file will
proceed to fill up all available disk space if left unchecked.

With this fix, throw immediately when this happens as there is no
recovery even if the network connection comes back up.
ferventcoder added a commit that referenced this issue Jul 25, 2015
* stable:
  (GH-285) Fix download loop if connection lost
  (maint) formatting
  (doc) add changelog for GH-353
@ferventcoder
Copy link
Member

This has been fixed for 0.9.9.9.

@ferventcoder ferventcoder changed the title Infinite loop in Get-WebFile.ps1 if connection is lost Infinite loop in Get-WebFile if connection is lost Jul 25, 2015
@ferventcoder ferventcoder changed the title Infinite loop in Get-WebFile if connection is lost Infinite loop downloading files if connection is lost Jul 25, 2015
ferventcoder added a commit that referenced this issue Jul 25, 2015
ferventcoder added a commit that referenced this issue Jul 25, 2015
* stable:
  (doc) add GH-285 to changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants