Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

CheckUrl feature often timeouts #35

Closed
majkinetor opened this issue Oct 9, 2016 · 8 comments
Closed

CheckUrl feature often timeouts #35

majkinetor opened this issue Oct 9, 2016 · 8 comments

Comments

@majkinetor
Copy link
Owner

This feature timeouts quite frequently.

For instance, notepadplusplus package timeouts on my system:

PS C:\work\_\chocolatey-coreteampackages\automatic\notepadplusplus.commandline> $au_timeout = 10
PS C:\work\_\chocolatey-coreteampackages\automatic\notepadplusplus.commandline> .\update.ps1
notepadplusplus.commandline - checking updates using au version 2016.10.7.130154
Can't validate latest notepadplusplus.commandline URL (disable using $NoCheckUrl): 'https://notepad-plus-plus.org/repository/7.x/7.0/npp.7.Installer.x64.exe'
Exception calling "GetResponse" with "0" argument(s): "The operation has timed out"
At C:\Program Files\WindowsPowerShell\Modules\au\Public\Update-Package.ps1:116 char:26
+ ... f (!$res) { throw "Can't validate latest $($package.Name) URL (disabl ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Can't validate ... has timed out":String) [], RuntimeException
    + FullyQualifiedErrorId : Can't validate latest notepadplusplus.commandline URL (disable using $NoCheckUrl): 'https://notepad-plus-plus.org/repository/7.x/7.0/npp.
   7.Installer.x64.exe'
Exception calling "GetResponse" with "0" argument(s): "The operation has timed out"

This is my current implementation that I use becuase it doesn't download the file:

@RedBaron2
Copy link
Contributor

RedBaron2 commented Oct 15, 2016

Found a solution, but I do have a question about your request function?
Do you use $request.GetResponse() anywhere else?

The solution is easy
Solution:

function request( [string]$Url, $Timeout=100 ) {
    if ([string]::IsNullOrWhiteSpace($url)) {throw 'The URL is empty'}
    $request = [System.Net.WebRequest]::Create($Url)
    if ($Timeout)  { $request.Timeout = $Timeout*1000 }

    $myrequest = $request.GetResponse()
    $myrequest.Close()

}

I said it was easy.

@majkinetor
Copy link
Owner Author

Argh, damn, so you say its because I didn't close the request ?
Good find if so.... I will test it out ASAP. Thanks for looking into it @RedBaron2.

I don't use request anywhere else, but why is that relevant ? This kind of change can't make a problem.

majkinetor added a commit that referenced this issue Oct 15, 2016
…ake package name from job name if its not set.
@majkinetor
Copy link
Owner Author

OK, pushed it, we will see how it works generally, it solved notepadplusplus. There is also a new message now:

> .\update.ps1

notepadplusplus - checking updates using au version 2016.10.15.81014
URL check
  https://notepad-plus-plus.org/repository/7.x/7.0/npp.7.bin.x64.7z
  https://notepad-plus-plus.org/repository/7.x/7.0/npp.7.Installer.exe
  https://notepad-plus-plus.org/repository/7.x/7.0/npp.7.Installer.x64.exe
  https://notepad-plus-plus.org/repository/7.x/7.0/npp.7.bin.7z
nuspec version: 7.0
remote version: 7.0
No new version found

@RedBaron2
Copy link
Contributor

I'll look further into it.

@RedBaron2
Copy link
Contributor

RedBaron2 commented Oct 15, 2016

@majkinetor
OK found it

if (!$Force) {
            'No new version found' | result
            return $package
        }

        else { 'No new version found, but update is forced' | result; set_choco_fix }

You basically have a trailing else that will never be called.
Enjoy

@majkinetor
Copy link
Owner Author

majkinetor commented Oct 15, 2016

@RedBaron2
Copy link
Contributor

I'm sure it is possible for them both to be executed how they are now. It is just programming readability that may find it as a error (Like I did). Most blocks are like } else { not like
}
else { . This may just be my OCD acting up again. This caused me to miss read your statement earlier about the notepadplusplus text output. I thought it was supposed to force changes even if there are none.
My bad -_-

@majkinetor
Copy link
Owner Author

It looks like this is fixed with your code so I will close it. If it reapears again I'll reopen.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants