Skip to content

Fix /news failing when Chromium binary is not installed#30

Merged
Payel-git-ol merged 3 commits into
Payel-git-ol:masterfrom
konard:issue-29-8fbc824ebc18
May 31, 2026
Merged

Fix /news failing when Chromium binary is not installed#30
Payel-git-ol merged 3 commits into
Payel-git-ol:masterfrom
konard:issue-29-8fbc824ebc18

Conversation

@konard

@konard konard commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #29/news reported every source as failed: browserType.launch: Executable doesn't exist at ... and prompted to run npx playwright install, collecting 0 items from all 51 sources.

Root cause

detectPlaywrightFetcher() decided whether to use the headless-browser fetcher or the plain-HTTP fallback like this:

const { chromium } = await import('playwright');
chromium.executablePath();          // ← only computes the path, never checks it
return new PlaywrightNewsPageFetcher();

chromium.executablePath() returns the expected location of the Chromium binary; it does not verify the file is actually present. On a machine where npx playwright install was never run (the user's Windows setup), it returns a non-empty path to a missing file, so detection wrongly picked the Playwright fetcher — and then every source failed at chromium.launch() time. The HTTP fallback that already existed in the codebase was never reached.

Fix

  • Verify the binary exists on disk (existsSync(chromium.executablePath())) before selecting Playwright; otherwise use HttpNewsPageFetcher.
  • Runtime safety net — new ResilientNewsPageFetcher wraps the Playwright fetcher and switches to the HTTP fallback the first time a browser-launch error occurs, so a partially-installed browser no longer fails every source.
  • Clarified the README wording about when the HTTP fallback kicks in.

Tests

  • ResilientNewsPageFetcher falls back to HTTP fetching on a launch error and does not retry the broken browser on subsequent calls.
  • ResilientNewsPageFetcher rethrows non-launch errors (e.g. net::ERR_CONNECTION_REFUSED) instead of masking them.

All 128 tests pass; npm run typecheck and npm run build are clean.

How to reproduce / verify

On a machine without the Chromium binary installed, run /news. Before this change every source failed with Executable doesn't exist; after it, the crawler transparently uses the HTTP fetcher and collects items from static pages.

konard added 2 commits May 31, 2026 07:00
Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: Payel-git-ol#29
chromium.executablePath() returns the expected binary path without
verifying the file exists, so detectPlaywrightFetcher chose the
Playwright fetcher even when 'npx playwright install' was never run.
Every source then failed at launch with "browserType.launch:
Executable doesn't exist at ...".

- Verify the Chromium binary exists on disk before selecting Playwright;
  otherwise use the HTTP fallback fetcher.
- Add ResilientNewsPageFetcher that switches to the HTTP fallback at
  runtime if launching the browser still fails, so a single missing
  browser no longer fails every source.
- Add tests covering the launch-failure fallback and non-launch error
  propagation; clarify README wording.

Fixes Payel-git-ol#29
@konard konard changed the title [WIP] Task Fix /news failing when Chromium binary is not installed May 31, 2026
@konard konard marked this pull request as ready for review May 31, 2026 07:04
@konard

konard commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

The work is complete. Here's a summary of what I did.

Summary

Issue #29 — running /news failed every one of the 51 sources with browserType.launch: Executable doesn't exist at ... and collected 0 items, prompting the user to run npx playwright install.

Root cause

detectPlaywrightFetcher() in src/services/news-crawler.ts chose between the headless-browser fetcher and the plain-HTTP fallback by calling chromium.executablePath(). That call only computes the expected path of the Chromium binary — it does not verify the file exists. On a machine where npx playwright install was never run, it returns a non-empty path to a missing file, so the code wrongly selected the Playwright fetcher, which then failed at chromium.launch() for every source. The existing HTTP fallback was never reached.

Fix (src/services/news-crawler.ts)

  1. Disk check before selecting PlaywrightexistsSync(chromium.executablePath()); if the binary isn't there, use HttpNewsPageFetcher.
  2. Runtime safety net — new ResilientNewsPageFetcher wraps the Playwright fetcher and switches to the HTTP fallback the first time a browser-launch error occurs, so a partially-installed browser no longer fails every source. It rethrows non-launch errors so genuine failures aren't masked.
  3. Clarified README wording about when the HTTP fallback activates.

Tests (tests/news-crawler.test.ts)

  • Falls back to HTTP on a launch error and doesn't retry the broken browser.
  • Rethrows non-launch errors (e.g. net::ERR_CONNECTION_REFUSED).

Verification

PR: #30 (updated description, marked ready for review).


This summary was automatically extracted from the AI working session output.

@konard

konard commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $1.677268

📊 Context and tokens usage:

  • 70.1K / 1M (7%) input tokens, 13.6K / 128K (11%) output tokens

Total: (2.9K new + 55.8K cache writes + 2.0M cache reads) input tokens, 13.6K output tokens, $1.677268 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Model: Claude Opus 4.8 (claude-opus-4-8)

📎 Log file uploaded as Gist (1205KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@Payel-git-ol Payel-git-ol merged commit 9481ab6 into Payel-git-ol:master May 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task

2 participants