GopeedLab/gopeed · warning
native cookie access is unavailable
Error message
native cookie access is unavailable
What it means
SetCookie is an optional capability. The provider type-asserts the underlying webview.WebView to a private cookieSetter interface (SetCookie(webview.Cookie) error); when the concrete binding does not implement it, the assertion fails and this error returns. It is a feature probe, not a runtime fault — the webview itself is fine.
Source
Thrown at internal/webview/goprovider/provider.go:259
}
if cookie.Expires != "" {
if parsed, err := time.Parse(time.RFC3339Nano, cookie.Expires); err == nil {
item.Expires = parsed
}
}
result = append(result, item)
}
return result, nil
}
func (p *pageWrapper) SetCookie(cookie enginewebview.Cookie) error {
type cookieSetter interface {
SetCookie(cookie webview.Cookie) error
}
return p.dispatch(func(w webview.WebView) error {
setter, ok := w.(cookieSetter)
if !ok {
return fmt.Errorf("native cookie access is unavailable")
}
return setter.SetCookie(webview.Cookie{
Name: cookie.Name,
Value: cookie.Value,
Domain: cookie.Domain,
Path: cookie.Path,
Expires: cookie.Expires,
Secure: cookie.Secure,
HTTPOnly: cookie.HTTPOnly,
})
})
}
func (p *pageWrapper) DeleteCookie(cookie enginewebview.Cookie) error {
type cookieDeleter interface {
DeleteCookie(name string, domain string, path string) error
}
return p.dispatch(func(w webview.WebView) error {View on GitHub (pinned to 7b7327ffb3)
Solutions
- Fall back to setting cookies through JS: page.Execute with document.cookie
- Feature-detect once at startup (try a benign SetCookie) and remember the capability
- If native cookies are required, build/upgrade the webview binding so it implements the cookieSetter interface
Example fix
// before
err := page.SetCookie(cookie) // "native cookie access is unavailable"
// after
if err := page.SetCookie(cookie); err != nil {
_, err = page.Execute(fmt.Sprintf(
`() => { document.cookie = %q=%q; Path=%s; Domain=%s; }`,
cookie.Name, cookie.Value, cookie.Path, cookie.Domain))
} Defensive patterns
Strategy: fallback
Validate before calling
// Probe native cookie support once, then route accordingly
var nativeCookies bool
func detectCookieSupport(page enginewebview.Page) bool {
return page.SetCookie(enginewebview.Cookie{Name: "__probe", Value: "1", Path: "/"}) == nil
} Type guard
// Go's idiom for this probe is interface assertion (as the provider itself does):
type cookieSetter interface {
SetCookie(cookie webview.Cookie) error
}
func hasNativeSetCookie(w webview.WebView) bool {
_, ok := w.(cookieSetter)
return ok
} Try / catch
if err := page.SetCookie(cookie); err != nil {
if strings.Contains(err.Error(), "native cookie access is unavailable") {
return setCookieViaJS(page, cookie) // document.cookie fallback
}
return err
} Prevention
- Feature-detect cookie APIs at startup and cache the result per provider build
- Keep a JS-based cookie helper as the portable default
- Do not assume desktop-browser cookie semantics in embedded webviews
When it happens
Trigger: Calling SetCookie on a platform whose webview_go binding was built without the cookie extension; custom embedders that wrap or replace the native webview object and thereby hide the interface.
Common situations: Cross-platform code that worked on a patched build (e.g. one exposing SetCookie for WebView2) and then fails on stock upstream webview bindings; users migrating to a provider build with fewer native extensions.
Related errors
AI-assisted analysis of GopeedLab/gopeed@7b7327ffb3 (2026-08-16).
Data as JSON: /api/errors/d3db0d24e3579a73.
Report an issue: GitHub.