GopeedLab/gopeed · error

page not found

Error message

page not found

What it means

Runtime.getPage looks the page up by id under a mutex and fails when the id is no longer registered. closePage deletes the id, so the classic cause is using a PageHandle after Close() was called (or after the runtime shut down its pages). Methods routed through page() — cookies, and any future page-scoped API — return this error.

Source

Thrown at pkg/download/engine/webview/runtime.go:455

		if err != nil {
			return nil, false, err
		}
		if matched {
			return value, true, nil
		}
		if time.Now().After(deadline) {
			return nil, false, nil
		}
		time.Sleep(pollInterval)
	}
}

func (r *Runtime) getPage(id string) (Page, error) {
	r.mu.Lock()
	defer r.mu.Unlock()
	page, ok := r.pages[id]
	if !ok {
		return nil, fmt.Errorf("page not found")
	}
	return page, nil
}

func (r *Runtime) closePage(id string) error {
	r.mu.Lock()
	page, ok := r.pages[id]
	if !ok {
		r.mu.Unlock()
		return nil
	}
	delete(r.pages, id)
	r.mu.Unlock()
	return page.Close()
}

func parseOpenOptions(raw map[string]any) OpenOptions {
	return OpenOptions{

View on GitHub (pinned to 7b7327ffb3)

Solutions

  1. Track closed state in the caller and drop references after Close()
  2. Re-open the page (runtime open/NewPage) if you still need it after closing
  3. Guard double-close paths so lifecycle code runs exactly once

Example fix

// before
await page.close();
await page.setCookie({ name: 'sid', value: '1' }); // -> page not found
// after
await page.setCookie({ name: 'sid', value: '1' });
await page.close();
Defensive patterns

Strategy: validation

Validate before calling

// JS: track page lifecycle in the caller
const pages = new Map(); // id -> { handle, closed }
async function safeCookie(id, cookie) {
  const p = pages.get(id);
  if (!p || p.closed) throw new Error('page is closed; open it again');
  return p.handle.setCookie(cookie);
}

Try / catch

try {
  await page.getCookies();
} catch (e) {
  if (String(e).includes('page not found')) {
    // page was closed elsewhere: re-open and rebuild state instead of retrying
  }
}

Prevention

When it happens

Trigger: Calling page.GetCookies()/SetCookie(...) after await page.close(); keeping a handle in a long-lived map while a script closes the tab; runtime-wide Close() followed by use of a previously opened handle.

Common situations: Cleanup code running twice (deferred close plus explicit close) and then a final status read; automation scripts that close pages on navigation events but keep references for later checks.

Related errors


AI-assisted analysis of GopeedLab/gopeed@7b7327ffb3 (2026-08-16). Data as JSON: /api/errors/feaa77f650a1c243. Report an issue: GitHub.