Fix browser download directory to automatically use /shared-downloads in Docker#3
Closed
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Closed
Conversation
… in Docker - Add model validator to BrowserProfile that sets downloads_path to /shared-downloads in Docker environments - Add Chrome --download-default-directory flag when downloads_path is configured - Ensures downloads go directly to shared directory without manual save_as() calls - Fixes issue where save_as() resulted in empty files due to temp location copying Co-Authored-By: jerry@browserless.io <jerry@browserless.io>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix browser download directory to automatically use /shared-downloads in Docker
Summary
This PR fixes a critical issue where browser downloads in Docker environments were failing to save properly to the
/shared-downloadsdirectory. The root cause was that Chrome was downloading files to temporary locations, and whensave_as()was called to copy them to/shared-downloads, the files ended up empty.The fix automatically configures Chrome's download directory to
/shared-downloadsin Docker environments by:BrowserProfilethat setsdownloads_path = '/shared-downloads'whenIN_DOCKER=Trueand no explicit path is configured--download-default-directoryChrome launch argument whendownloads_pathis setThis ensures downloads go directly to the shared directory without requiring manual
save_as()calls that were causing empty files.Review & Testing Checklist for Human
--download-default-directoryworks correctly across different Chrome versions and doesn't cause browser launch issuesdownloads_pathconfigurations still work as expectedIN_DOCKERflag is reliable in your Docker environments and activates the feature when neededRecommended test plan: Set up a Docker container with
/shared-downloadsmounted, run the original failing script, and verify downloaded files contain expected content instead of being empty.Diagram
%%{ init : { "theme" : "default" }}%% graph TB subgraph "Browser Profile System" Profile["browser_use/browser/profile.py"]:::major-edit Session["browser_use/browser/session.py"]:::context Context["browser_use/browser/context.py"]:::context end subgraph "Docker Environment" Docker["IN_DOCKER flag"]:::context SharedDir["/shared-downloads"]:::context end subgraph "Chrome Launch" ChromeArgs["Chrome Arguments"]:::minor-edit DownloadDir["--download-default-directory"]:::major-edit end Profile --> ChromeArgs Profile --> DownloadDir Docker --> Profile SharedDir --> DownloadDir Session --> Profile Context --> Profile subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#F5F5F5Notes
save_as()was creating empty files due to copying from temporary Chrome download locations