mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-15 22:15:00 +00:00
feat(browser): add timeout, idle auto-close, and max-pages safety mechanisms
Prevent resource leaks and hanging actions in the browser tool: - Per-action context timeout (default 30s, configurable via timeoutMs param or config) - Idle page reaper goroutine closes pages unused for 10min (configurable) - Max pages per tenant (default 5) with LRU eviction - RefStore cleanup on page close/evict/reap to prevent memory leaks
This commit is contained in:
1 parent
afbecd3e4c
commit
ee4d34ae28
8 files changed
+226
-12
No files matched your search
@@ -151,6 +151,18 @@ func (t *BrowserTool) Execute(ctx context.Context, args map[string]any) *tools.R
|
||||
}
|
||||
}
|
||||
|
||||
// Apply per-action timeout for heavy operations
|
||||
switch action {
|
||||
case "open", "navigate", "snapshot", "screenshot", "act":
|
||||
timeout := t.manager.ActionTimeout()
|
||||
if ms, ok := args["timeoutMs"].(float64); ok && ms > 0 {
|
||||
timeout = time.Duration(ms) * time.Millisecond
|
||||
}
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
}
|
||||
|
||||
switch action {
|
||||
case "status":
|
||||
return t.handleStatus()
|
||||
|
||||
Reference in new issue
Block a user