-
-
Notifications
You must be signed in to change notification settings - Fork 13
Test/wpt error handling #247
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
Conversation
WalkthroughThis PR refactors the WPT test pipeline: adds a runtime-controlled concurrency cap ( Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Don't panic if parsing json fails.
9eaae8c to
5dc2a15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
| func (s manifestTestCaseSource) fetchManifest(ctx context.Context) (res *http.Response, err error) { | ||
| var req *http.Request | ||
| req, err = http.NewRequestWithContext(ctx, http.MethodGet, s.href, nil) | ||
| if err != nil { | ||
| panic(fmt.Sprintf("load manifest: create request: %v", err)) | ||
| err = fmt.Errorf("load manifest: create request: %w", err) | ||
| return | ||
| } | ||
| res, err := http.DefaultClient.Do(req) | ||
| res, err = http.DefaultClient.Do(req) | ||
| if err != nil { | ||
| panic(fmt.Sprintf("load manifest: %v", err)) | ||
| err = fmt.Errorf("load manifest: %w", err) | ||
| } | ||
| ch := make(chan TestCase) | ||
| return | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close response body on Do error to prevent leaks.
http.Client.Do can return a non-nil res with err; not closing res.Body can leak connections.
🩹 Proposed fix
res, err = http.DefaultClient.Do(req)
if err != nil {
+ if res != nil && res.Body != nil {
+ res.Body.Close()
+ }
+ res = nil
err = fmt.Errorf("load manifest: %w", err)
return
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func (s manifestTestCaseSource) fetchManifest(ctx context.Context) (res *http.Response, err error) { | |
| var req *http.Request | |
| req, err = http.NewRequestWithContext(ctx, http.MethodGet, s.href, nil) | |
| if err != nil { | |
| panic(fmt.Sprintf("load manifest: create request: %v", err)) | |
| err = fmt.Errorf("load manifest: create request: %w", err) | |
| return | |
| } | |
| res, err := http.DefaultClient.Do(req) | |
| res, err = http.DefaultClient.Do(req) | |
| if err != nil { | |
| panic(fmt.Sprintf("load manifest: %v", err)) | |
| err = fmt.Errorf("load manifest: %w", err) | |
| } | |
| ch := make(chan TestCase) | |
| return | |
| } | |
| func (s manifestTestCaseSource) fetchManifest(ctx context.Context) (res *http.Response, err error) { | |
| var req *http.Request | |
| req, err = http.NewRequestWithContext(ctx, http.MethodGet, s.href, nil) | |
| if err != nil { | |
| err = fmt.Errorf("load manifest: create request: %w", err) | |
| return | |
| } | |
| res, err = http.DefaultClient.Do(req) | |
| if err != nil { | |
| if res != nil && res.Body != nil { | |
| res.Body.Close() | |
| } | |
| res = nil | |
| err = fmt.Errorf("load manifest: %w", err) | |
| } | |
| return | |
| } |
No description provided.