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
| 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.
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.