xtekky/gpt4free · error · TimeoutError
Timeout waiting for Cloudflare response
Error message
Timeout waiting for Cloudflare response
What it means
IsTermuxInstalled runs `pm list packages` via exec and cmd.Output() failed. On Android this means the pm binary was not found on PATH, was not executable from this process context, or exited non-zero; the %w wraps the underlying exec error. Note the function already returns a separate error when GOOS != android, so this one is Android-execution-specific.
Source
Thrown at g4f/Provider/Cloudflare.py:234
while True:
try:
event = await asyncio.wait_for(q.get(), timeout=30.0)
args = event.get("args", [])
if args and args[0].get("type") == "string":
val = args[0].get("value", "")
if val == last_val:
continue
last_val = val
if val.startswith("CF_CHUNK: "):
yield val[10:]
elif val == "CF_DONE":
break
elif val == "CF_ERROR":
raise RuntimeError(
"WebSocket error inside Cloudflare session"
)
except asyncio.TimeoutError:
raise TimeoutError("Timeout waiting for Cloudflare response")
finally:
session.remove_event_handler("Runtime.consoleAPICalled", q)
await session.close()
View on GitHub (pinned to 973504e177)
Solutions
- Check the wrapped err: exec.ErrNotFound means PATH lacks pm — use the absolute path /system/bin/pm in the exec.Command call
- Confirm you are running inside a proper Android app context (Termux), not a raw adb shell with a minimal PATH
- If SELinux is the cause (see logcat), run from the Termux app context where exec of system tools is permitted
- Fall back to detecting Termux by filesystem probe (e.g. stat /data/data/com.termux) when pm is unavailable
Example fix
// before
cmd := exec.Command("pm", "list", "packages")
// after
cmd := exec.Command("/system/bin/pm", "list", "packages") Defensive patterns
Strategy: fallback
Validate before calling
func termuxAvailable() bool {
if _, err := exec.LookPath("pm"); err != nil {
if _, statErr := os.Stat("/system/bin/pm"); statErr != nil {
return false
}
}
if _, err := os.Stat("/data/data/com.termux"); err == nil {
return true // filesystem probe works without pm
}
out, err := exec.Command("/system/bin/pm", "list", "packages").Output()
return err == nil && strings.Contains(string(out), "com.termux")
} Try / catch
installed, err := IsTermuxInstalled()
if err != nil {
// do not treat a broken pm as 'no termux'; fall back to filesystem detection
installed = termuxAvailable()
} Prevention
- Invoke pm by absolute path /system/bin/pm rather than relying on PATH
- Keep a filesystem-based Termux probe as fallback for restricted shells
When it happens
Trigger: Running inside a non-Termux Android context (e.g. a plain adb shell or an app sandbox) where pm is not on PATH; SELinux denying exec of pm; pm exiting non-zero because of a dead package manager session; Termux environment where PATH was reset.
Common situations: Testing the Go binary via adb shell instead of inside Termux; CI/emulator images with restricted shells; devices where pm requires a specific user context; PATH stripped by su or a wrapper script.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Install or update "curl_cffi" package | pip install -U curl_
- Status 401: Invalid session
- Error: {msg}
- Missing cookie: {cls.anon_cookie_name}
- Invalid response: {last_msg}
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/16269946e9c0bf9a.
Report an issue: GitHub.