-
Notifications
You must be signed in to change notification settings - Fork 239
Description
Describe the bug
When using remote CDP mode, the Chrome browser on the remote machine (192.168.248.222) closes immediately as soon as any opencli command finishes, even though:
OPENCLI_CDP_ENDPOINT is correctly set to a remote Chrome instance
OPENCLI_CDP_ONLY=true is explicitly set
opencli doctor shows [OK] CDP endpoint and "Remote Chrome mode: extension token not required"
Chrome is started with proper flags: --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --remote-allow-origins="*"
This happens on both v0.9.8 (before and after npm install -g @jackwener/opencli@latest).
To Reproduce
On remote machine (192.168.248.222):Bashnohup google-chrome
--remote-debugging-port=9222
--remote-debugging-address=0.0.0.0
--user-data-dir="$HOME/chrome-debug-profile-opencli"
--remote-allow-origins="*"
--no-first-run
--disable-background-mode > /dev/null 2>&1 &
On client machine:Bashexport OPENCLI_CDP_ENDPOINT="http://192.168.248.222:9222"
export OPENCLI_CDP_ONLY="true"
opencli doctor # → shows OK
opencli zhihu search --keyword "test" # command runs, but browser closes right after
Expected behavior
In pure CDP/remote mode, OpenCLI should only connect to the existing Chrome instance and never close or kill it after the command finishes. The browser should remain open until the user manually closes it.
Actual behavior
Browser process disappears immediately after the command exits.
Environment
opencli version: 0.9.8 (latest as of Mar 19, 2026)
Chrome: latest stable (started with CDP flags)
OS (remote): Linux (Ubuntu/Debian on 2080ti)
OS (client): macOS / Linux (using export)
Connection: direct IP (no SSH tunnel in this test)
Additional context
CDP support was added very recently (19 hours ago).
This makes remote/headless usage almost unusable, because the whole point of CDP is to keep a persistent Chrome session with login cookies.
Workaround tried: nohup, tmux, separate --user-data-dir, but still closes.
Would be great if we can add an environment variable like OPENCLI_KEEP_BROWSER_OPEN=true or make CDP mode truly non-destructive by default.
Thanks!