Skip to content

Site adapters fail with 'Failed to fetch' while eval works fine #41

Description

@osen77

Environment

  • bb-browser: v0.8.0
  • Chrome: 145 (macOS)
  • OS: macOS (Apple Silicon)
  • Network: Clash TUN mode (system-wide proxy)
  • Mode: Standalone (Chrome extension + daemon)

Bug Description

Site adapters consistently fail with TypeError: Failed to fetch, but running the exact same fetch() call via bb-browser eval works perfectly. This suggests a difference in the execution context between site adapters and eval.

Steps to Reproduce

  1. Install bb-browser, load Chrome extension, run bb-browser site update
  2. Verify extension is connected: bb-browser status → "浏览器运行中"
  3. Run any site adapter:
$ bb-browser site hackernews/top 3
[error] site hackernews/top: Uncaught (in promise) TypeError: Failed to fetch
  Hint: Open https://news.ycombinator.com in your browser, make sure you are logged in, then retry.
  1. Run the exact same fetch via eval — works fine:
$ bb-browser eval "fetch('https://hacker-news.firebaseio.com/v0/topstories.json').then(r=>r.json()).then(ids=>ids.slice(0,3))"
[47392084, 47390817, 47390945]

Additional observations

  • The first site hackernews/top call after installing the extension succeeded and returned valid JSON data
  • All subsequent calls fail with the same error
  • Tested multiple adapters (hackernews/top, baidu/search, zhihu/hot) — all fail identically
  • bb-browser eval "fetch('https://httpbin.org/get').then(r=>r.json())" also works fine
  • Switching to the target tab first (bb-browser tab 3) does not help
  • Restarting the daemon does not help
  • Tab listing works, browser status reports connected

Expected behavior

Site adapters should execute fetch() in the same page context as eval, and return data successfully.

Suspected cause

Site adapter code appears to run in a different execution context (extension Service Worker? isolated world?) compared to eval, where fetch() fails — possibly due to CORS, CSP, or Chrome MV3 Service Worker restrictions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions