Skip to content

Fix #93 context deadline exceeded #94

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

Merged
merged 1 commit into from
May 24, 2025
Merged

Fix #93 context deadline exceeded #94

merged 1 commit into from
May 24, 2025

Conversation

acirep
Copy link
Collaborator

@acirep acirep commented May 19, 2025

Increased timeout from 2 to 3 seconds and added more friendly error message in case of "context deadline exceeded" error (timeout).

@bsiegert please review and tests if possible, it passed my local tests.

@acirep acirep requested a review from bsiegert May 19, 2025 19:54
Copy link
Owner

@bsiegert bsiegert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contributions!

My comment is just a tiny nit. I'll merge and make the change myself if that's okay.

@@ -196,15 +196,23 @@ func PkgInfo(w io.Writer, res ddao.GetSingleResultRow) {
req, err := http.NewRequestWithContext(ctx, "GET", reqURL, nil)
if err != nil {
results[index].StatusCode = http.StatusInternalServerError
results[index].Error = err.Error()
if err == context.DeadlineExceeded {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be errors.Is.

return
}

// Make the request
resp, err := http.DefaultClient.Do(req)
if err != nil {
results[index].StatusCode = http.StatusInternalServerError
results[index].Error = err.Error()
if err == context.DeadlineExceeded || err.Error() == "context deadline exceeded" {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that with errors.Is, the second clause won't be needed, as this will fire even for a wrapped DeadlineExceeded.

@bsiegert bsiegert merged commit 4fe25b1 into bsiegert:sql May 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants