mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-12 19:33:41 +00:00
fix(http): reset discarded prefetch progress on resume (#1462)
This commit is contained in:
6 files changed
+93
-9
No files matched your search
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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/",
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user