Skip to content

fix(auth): remove headed probe cache and add settling delay#70

Merged
avifenesh merged 4 commits intomainfrom
fix/auth-wall-headed-checkpoint-67
Feb 25, 2026
Merged

fix(auth): remove headed probe cache and add settling delay#70
avifenesh merged 4 commits intomainfrom
fix/auth-wall-headed-checkpoint-67

Conversation

@avifenesh
Copy link
Collaborator

Summary

  • Fix race condition where canLaunchHeaded() fails because Chromium OS-level cleanup hasn't finished after closeBrowser() resolves
  • Remove permanent _headedResult cache that prevented retry after transient failures
  • Add retry logic (2 attempts, 500ms delay) to canLaunchHeaded() for transient resource contention
  • Add 500ms settling delay between closeBrowser() and canLaunchHeaded() in the goto auth wall path

Root Cause

When goto detects an auth wall, it closes the headless browser and immediately calls canLaunchHeaded(). The probe launch fails because Chromium hasn't released OS resources yet (file locks, display). The failure was permanently cached in _headedResult, preventing any retry.

Test Plan

  • 487/487 tests pass (8 new tests added)
  • Source-inspection tests verify cache removal, retry logic, settling delay, and error logging
  • Behavioral tests verify DISPLAY/WAYLAND_DISPLAY env var handling and cache-free re-evaluation
  • npm run validate passes

Closes #67

The headless-to-headed browser handoff during auth wall detection was
failing because canLaunchHeaded() cached a stale false result and the
Chromium process had not fully released OS resources before the headed
probe launched. Remove the _headedResult cache so each auth wall event
gets a fresh probe, add a retry loop (2 attempts with 500ms backoff),
log errors on final failure, and insert a 500ms settling delay between
closeBrowser and canLaunchHeaded in the goto auth wall path.
…scope

Move playwright require inside try/catch so MODULE_NOT_FOUND is handled
by retry logic. Add two behavioral tests:
- canLaunchHeaded returns false without DISPLAY env vars
- canLaunchHeaded re-evaluates on each call (no stale cache)
- Use console.warn instead of console.error for [WARN] level message
  to match codebase conventions (web-ctl.js uses console.warn throughout)
- Add behavioral test for WAYLAND_DISPLAY env var support
- Keep require('playwright') inside try/catch to handle missing module
Keep both auth wall headed checkpoint fix tests and new
waitForLoaded feature tests from main.
@avifenesh avifenesh merged commit d511c0a into main Feb 25, 2026
2 checks passed
@avifenesh avifenesh deleted the fix/auth-wall-headed-checkpoint-67 branch February 25, 2026 14:58
avifenesh added a commit that referenced this pull request Feb 25, 2026
Keep improved timeout validation from feature branch and incorporate
auth wall checkpoint tests from main.
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.

Auth wall detection closes browser but fails to open headed checkpoint

1 participant