agentscope-ai / agentscope-ai/QwenPaw
[Bug] Plugin import failure blocks startup for 6+ minutes, all channels unresponsive
- Lenguaje dominante
- Python
- Estrellas
- 34.9k
- Forks
- 3.1k
- Merge medio
- 1 d 15 h
- PR fusionados (30 d)
- 225
Descripción
## Description
When a plugin has an unresolvable `ImportError` (e.g., missing third-party dependency), QwenPaw's startup is blocked for **6+ minutes**. During this time, all channels (Feishu, QQ, etc.) are completely unresponsive — messages are silently dropped.
## Steps to Reproduce
1. Install a plugin that imports `psycopg2` (or any non-installed package)
2. Restart QwenPaw
3. Observe startup takes 393 seconds instead of normal ~140 seconds
4. All incoming messages during startup window get no response
## Expected Behavior
- Plugin loading failure should **not** block the entire startup
- Failed plugins should be skipped with a logged error
- Core services (channels, API) should start normally regardless of plugin failures
## Actual Behavior
- Plugin `ImportError` causes 393-second startup delay (vs normal 139 seconds)
- All channels (Feishu, QQ) are unreachable during this window
- User messages sent during startup are lost with no response
## Logs
### Failed startup (psycopg2 missing) — 393 seconds
```
2026-06-03 23:42:56 | INFO | plugins/loader.py:53 | Scanning plugin directory: /app/working/plugins
2026-06-03 23:42:56 | INFO | plugins/loader.py:66 | Discovered plugin: quick-commands
2026-06-03 23:42:56 | ERROR | plugins/loader.py:315 | Failed to load plugin 'quick-commands': No module named 'psycopg2'
Traceback (most recent call last):
File "/app/venv/lib/python3.11/site-packages/qwenpaw/plugins/loader.py", line 272, in load_plugin
spec.loader.exec_module(module)
File "/app/working/plugins/quick-commands/plugin.py", line 21, in
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
2026-06-03 23:42:56 | ERROR | plugins/loader.py:354 | Failed to load plugin 'quick-commands': No module named 'psycopg2'
...
2026-06-03 23:42:56 | INFO | app/_app.py:450 | Background startup completed in 393.072 seconds
```
### Normal startup — 139 seconds
```
2026-06-02 20:47:03 | INFO | plugins/loader.py:237 | ✓ Loaded plugin 'quick-commands' successfully
2026-06-02 20:47:03 | INFO | app/_app.py:450 | Background startup completed in 139.032 seconds
```
### Historical comparison
```
2026-06-01 22:25:38 | Background startup completed in 142.753 seconds (normal)
2026-06-01 23:00:35 | Background startup completed in 147.129 seconds (normal)
2026-06-02 20:47:03 | Background startup completed in 139.032 seconds (normal)
2026-06-03 23:42:56 | Background startup completed in 393.072 seconds (FAILED — 2.8x slower)
```
## Root Cause Analysis
The plugin loader appears to block the startup sequence when a plugin fails to import. The 393-second delay likely comes from:
1. Plugin import timeout/retry logic
2. Possible cascading effects on other initialization steps
This creates a dangerous situation: a single broken plugin can make the entire QwenPaw instance unresponsive for 6+ minutes.
## Suggested Fix
```python
# In plugins/loader.py load_plugin()
try:
spec.loader.exec_module(module)
except ImportError as e:
logger.error(f"Plugin '{plugin_name}' skipped due to import error: {e}")
# Continue startup, don't block
return None
except Exception as e:
logger.error(f"Plugin '{plugin_name}' failed to load: {e}")
return None
```
Additionally, consider adding a timeout wrapper around plugin loading to prevent any single plugin from blocking startup indefinitely.
## Environment
- QwenPaw version: 1.1.10
- Deployment: Docker on NAS
- Affected channels: All (Feishu, QQ, Console)
- Missing dependency: `psycopg2-binary==2.9.12`
## Workaround
We added auto-install logic in the plugin itself:
```python
try:
import psycopg2
except ImportError:
import subprocess, sys
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'psycopg2-binary', '-q'])
import psycopg2
```
This is a workaround, not a fix. The framework should be resilient to plugin failures.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.