Process Cleanup & Troubleshooting
🧹 Process Cleanup & Troubleshooting
Section titled “🧹 Process Cleanup & Troubleshooting”Bflow is engineered with robust lifecycle management. However, unexpected system crashes or forced terminal terminations (Ctrl + C) can occasionally leave headless Chrome processes running in the background.
Here is how to resolve common operational issues.
🧹 Orphan Process Cleanup
Section titled “🧹 Orphan Process Cleanup”If you ever suspect lingering headless Chrome processes are consuming RAM or locking DevTools ports:
bun cleanupOr programmatically:
import { Browser } from "./cdp/index.js";
const killed = await Browser.cleanupOrphans();console.log(`Terminated ${killed} orphan Chrome instances.`);What bun cleanup Does:
Section titled “What bun cleanup Does:”- Searches system processes for Chrome instances launched with
--remote-debugging-port. - Matches flags used specifically by the CLI (e.g.
--user-data-dircontaining temporary automation profiles). - Safely sends
SIGTERMand cleans up temporary profile directories.
🔍 Common Issues & Solutions
Section titled “🔍 Common Issues & Solutions”1. “Chrome not found in standard system locations”
Section titled “1. “Chrome not found in standard system locations””- Cause: Chrome is installed in a non-standard directory or using a custom Chromium build.
- Solution: Set the
CHROME_PATHenvironment variable:Terminal window export CHROME_PATH="/opt/google/chrome/chrome"
2. “CDP WebSocket connection timeout”
Section titled “2. “CDP WebSocket connection timeout””- Cause: Port collision or Chrome taking too long to launch.
- Solution:
- Run
bun cleanupto release any stale ports. - Increase timeout if running on resource-constrained CI machines:
const browser = await Browser.launch({ timeout: 15000 });
- Run
3. “Element not found or interaction timed out”
Section titled “3. “Element not found or interaction timed out””- Cause: The element may be loaded asynchronously or inside an iframe.
- Solution:
- Add a
waitForSelectorstep before clicking or typing. - Use a case-insensitive locator:
text/i="submit". - Replay in headed mode (
--headed) to visually observe the page layout.
- Add a
4. Headless Mode vs Headed Mode differences
Section titled “4. Headless Mode vs Headed Mode differences”Some websites detect headless Chrome and present bot challenges (Cloudflare / CAPTCHA).
- Tip: Test in headed mode first (
bun flow workflow.json --headed). - During visual recording, use ⏸️ Pause on the HUD to complete verification challenges manually before resuming recording.