fix(http): reset discarded prefetch progress on resume (#1462)

This commit is contained in:
Levi authored and GitHub committed 2026-08-31 23:05:01 +08:00
1 parent 962ff4dc98
commit c5c8bb2bf5
6 files changed
+93 -9

No files matched your search

+5 -1
View File
@@ -81,6 +81,10 @@ type nativeCookieJSON struct {
var providerSeq atomic.Uint64
// Keep native page creation aligned with the provider availability budget used
// by the integration contract. Cold WebView2 startup can exceed ten seconds.
const startupTimeout = time.Minute
func newPageWrapper(opts enginewebview.OpenOptions) *pageWrapper {
seq := providerSeq.Add(1)
return &pageWrapper{
@@ -142,7 +146,7 @@ func (p *pageWrapper) start() error {
case err := <-p.ready:
p.tracef("open %dms", time.Since(startedAt).Milliseconds())
return err
case <-time.After(10 * time.Second):
case <-time.After(startupTimeout):
p.tracef("open timeout %dms", time.Since(startedAt).Milliseconds())
return fmt.Errorf("webview startup timeout")
}
+5 -1
View File
@@ -14,6 +14,10 @@ import (
const TestUserAgent = "GopeedWebViewIntegration/1.0"
// Providers may need to initialize an external host or a native browser runtime
// before the first page can be created.
const defaultAvailabilityTimeout = time.Minute
type ContractOptions struct {
AvailabilityTimeout time.Duration
CookieDomainMode CookieDomainMode
@@ -32,7 +36,7 @@ func RunProviderContract(t *testing.T, provider enginewebview.Provider, opts Con
timeout := opts.AvailabilityTimeout
if timeout <= 0 {
timeout = 10 * time.Second
timeout = defaultAvailabilityTimeout
}
waitForProviderAvailable(t, provider, timeout)
@@ -7,7 +7,6 @@ import (
"os"
"path/filepath"
"testing"
"time"
"github.com/GopeedLab/gopeed/internal/webview/integrationtest"
enginewebview "github.com/GopeedLab/gopeed/pkg/download/engine/webview"
@@ -26,9 +25,8 @@ func TestProviderContract(t *testing.T) {
Token: *webViewRPCToken,
})
integrationtest.RunProviderContract(t, provider, integrationtest.ContractOptions{
AvailabilityTimeout: 5 * time.Minute,
CookieDomainMode: integrationtest.CookieDomainModeRequired,
CookieTestURL: "https://example.com/",
CookieDomainMode: integrationtest.CookieDomainModeRequired,
CookieTestURL: "https://example.com/",
})
}