Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix: close original image after overlay to prevent fd leak

itxaiohangloverfe8d51ced20d
diff --git a/browser_use/agent/gif.py b/browser_use/agent/gif.py
index 8a02e96d5..063620e40 100644
--- a/browser_use/agent/gif.py
+++ b/browser_use/agent/gif.py
@@ -179,7 +179,7 @@ def create_history_gif(
image = Image.open(io.BytesIO(img_data))
if show_goals and item.model_output:
- image = _add_overlay_to_image(
+ overlay = _add_overlay_to_image(
image=image,
step_number=i,
goal_text=item.model_output.current_state.next_goal,
@@ -188,6 +188,8 @@ def create_history_gif(
margin=margin,
logo=logo,
)
+ image.close()
+ image = overlay
images.append(image)