mirror of
https://github.com/browser-use/browser-use
synced 2026-04-22 17:45:09 +02:00
Two issues flagged by automated review on #4711: 1. (P1, Codex) The 90s default was *below* the extract action's intentional 120s page_extraction_llm.ainvoke timeout (tools/service.py:1096,1172). Slow-but-valid extractions against large pages would be truncated into timeout errors — a regression. Raised default to 180s, which sits above that 120s inner cap with grace. 2. (P2, Cubic + Codex) float(os.getenv('BROWSER_USE_ACTION_TIMEOUT_S', '90')) ran at import time. An empty or non-numeric value (common with env templating) raised ValueError and prevented browser_use.tools.service from importing at all — turning a config typo into a process-wide startup failure. Wrapped in try/except with a warning and fallback to the hardcoded 180s default. Tests: - test_default_action_timeout_accommodates_extract_action — pins the default >= 150s so future edits can't silently regress extract. - test_malformed_env_timeout_does_not_break_import — reloads the module with empty / non-numeric env values and asserts it falls back cleanly, plus verifies a valid numeric env value still takes effect.
Codebase Structure
The code structure inspired by https://github.com/Netflix/dispatch.
Very good structure on how to make a scalable codebase is also in this repo.
Just a brief document about how we should structure our backend codebase.
Code Structure
src/
/<service name>/
models.py
services.py
prompts.py
views.py
utils.py
routers.py
/_<subservice name>/
Service.py
Always a single file, except if it becomes too long - more than ~500 lines, split it into _subservices
Views.py
Always split the views into two parts
# All
...
# Requests
...
# Responses
...
If too long → split into multiple files
Prompts.py
Single file; if too long → split into multiple files (one prompt per file or so)
Routers.py
Never split into more than one file