mirror of
https://github.com/browser-use/browser-use
synced 2026-04-22 17:45:09 +02:00
## Summary
Fixes #4046
The skill CLI crashes on startup when `lmnr` is installed but internally
broken (e.g., Python 3.13 with certain package states). The import
raises `TypeError` instead of `ImportError`, which escapes the existing
handler and kills the entire application.
## Root Cause
`browser_use/observability.py` line 52 only catches `ImportError`, but a
broken `lmnr` installation can raise `TypeError` during its internal
initialization.
## Fix
Broadened `except ImportError` to `except (ImportError, TypeError)` so
the no-op fallback decorator is used in both failure modes. Chose
specific exceptions over `except Exception` to avoid masking unrelated
errors.
## Tests Added
New file: `tests/ci/test_observability.py` with 4 tests:
- `test_fallback_when_lmnr_not_installed` ImportError fallback
- `test_fallback_when_lmnr_raises_type_error` TypeError fallback
(regression for #4046)
- `test_observe_noop_decorator_works_on_sync_function` sync decorator
verification
- `test_observe_noop_decorator_works_on_async_function` async decorator
verification
All pass. Happy to adjust based on feedback!
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes a startup crash in the skill CLI when `lmnr` is installed but
broken by catching `TypeError` during import and falling back to the
no-op observe decorator. Keeps the CLI running even if observability is
unavailable.
- **Bug Fixes**
- Catch `(ImportError, TypeError)` in `browser_use/observability.py` and
disable observability when `lmnr` fails to import.
<sup>Written for commit 80f798bc17.
Summary will update on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
This commit is contained in:
@@ -49,7 +49,7 @@ try:
|
||||
if os.environ.get('BROWSER_USE_VERBOSE_OBSERVABILITY', 'false').lower() == 'true':
|
||||
logger.debug('Lmnr is available for observability')
|
||||
_LMNR_AVAILABLE = True
|
||||
except ImportError:
|
||||
except (ImportError, TypeError):
|
||||
if os.environ.get('BROWSER_USE_VERBOSE_OBSERVABILITY', 'false').lower() == 'true':
|
||||
logger.debug('Lmnr is not available for observability')
|
||||
_LMNR_AVAILABLE = False
|
||||
|
||||
Reference in New Issue
Block a user