gomods / athens

A Go module datastore and proxy
https://docs.gomods.io
MIT License
4.41k stars 497 forks source link

Enforce timeout on vcsLister.List() #1884

Open colinodell opened 1 year ago

colinodell commented 1 year ago

Is your feature request related to a problem? Please describe.

When listing available versions for certain modules, vcsLister.List() can sometimes take several minutes to execute. I would like to configure a timeout on that operation so proxy users aren't stuck waiting that long for a response.

Describe the solution you'd like

Have the vcsLister respect the existing ATHENS_TIMEOUT setting already used by storage backends.

Describe alternatives you've considered

None

Additional context

Run go list -m -versions -json github.com/aws/aws-sdk-go-v2/credentials/v2@latest to see an example of one such module that takes a really long time to list versions for.

Here's a trace from athens for that same module:

image

ngshiheng commented 11 months ago

I actually like the idea of having a timeout for this. I recently stumbled upon a similar situation.

Just to give a quick comparison, Go's official module proxy mirror responds almost immediately when we do: https://proxy.golang.org/github.com/grpc-ecosystem/grpc-gateway/v3/@v/list (404)

On the other hand, https://athens.private.com/github.com/grpc-ecosystem/grpc-gateway/v3/@v/list took ~9s to return 200. For bigger modules like aws-sdk-go, it could take much longer as you described.

Response code aside, I'm not sure if Athens wants to do the same thing here. Maybe others can chime in.

Anyway, @colinodell i see that you're using Renovate for this from your user-agent. Here's how I reduced the response wait time when using Renovate (35.138.1-slim):

hostRules: [
        {
            hostType: "go-proxy",
            description: "Avoid waiting 1 min/req to wait for go-proxy to respond if a module version list does not exist",
            timeout: 5000, // milliseconds
        },
    ],

I hope this can temporarily relieve the wait a bit for your use case

taylorychen commented 1 month ago

can I work on this?

matt0x6F commented 2 weeks ago

can I work on this?

@taylorychen go for it! You don't need to ask, just deliver a PR.