[🐛 Bug]: [rust] Selenium Manager can return a browser from the cache before it finishes copying

Aperta
#18,427 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Liz-Lian ci sta già lavorando.

Dal 2/12/2026.

  • #18430 di @Liz-Lian — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend, databases

Direzione di ricerca

Read rust/src/lib.rs around download_browser (line 323) and the driver check (line 969), then inspect copy_folder_content in rust/src/files.rs (line 567). Reproduce with two Selenium Manager processes sharing a cache while Chrome is copied. Done means a process only receives the browser path after its files are fully available; the issue suggests atomic rename, a completion marker, or checking under the lock.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

C-rust I-defect
Description

When several Selenium Manager processes share a cache, one of them can get a browser path back while another process is still copying that browser into the cache. The browser then fails to start. With Chrome, chromedriver reports session not created: Chrome instance exited.

The cache lock added for #13511 and #13686 stops two processes from downloading at the same time. However, download_browser checks whether the browser binary exists before it takes the lock (rust/src/lib.rs:323). If the binary is there, it returns that path without waiting on the lock. The process doing the download holds the lock while it unzips into a temporary folder and then copies the files into the cache one at a time (copy_folder_content). The binary can be copied before the libraries and resources it needs. Any process that checks during that copy gets a path to an incomplete browser.

The driver has the same unlocked check (rust/src/lib.rs:969). The window there is smaller, since only a single file is copied.

This affects every binding, and any process that shares a cache folder: parallel test workers in one CI job, or several runners on one self-hosted machine.

Expected: a browser path is returned only once that browser is fully in the cache.

Possible fixes:

  • Unzip into a temporary folder inside the cache and rename it into place once complete. Alternatively, write a marker file last and check for the marker instead of the binary.
  • Check for the binary only after taking the lock. This is simpler, but every run then waits on the lock.
Reproducible Code
# Watches the cache while one process downloads Chrome for Testing.
# The browser binary appears long before the rest of the files.
SM=/path/to/selenium-manager
CACHE=$(mktemp -d)
"$SM" --browser chrome --browser-version 157 --force-browser-download \
  --cache-path "$CACHE" --output json > /dev/null 2>&1 &
PID=$!
while kill -0 $PID 2>/dev/null; do
  files=$(find "$CACHE/chrome" -type f 2>/dev/null | wc -l | tr -d ' ')
  binary=$(find "$CACHE/chrome" -type f \( -path '*MacOS/Google Chrome for Testing' -o -name chrome \) 2>/dev/null | wc -l | tr -d ' ')
  echo "files=$files binary=$binary"
  sleep 0.05
done | uniq

# Running a second selenium-manager with the same arguments while the
# output shows binary=1 and an incomplete file count makes it log
# "chrome ... already exists at ..." and return the incomplete browser.
Debugging Logs
# macOS arm64, Selenium Manager from selenium-webdriver 4.53.0
files=0 binary=0
files=1 binary=0
files=37 binary=1
files=349 binary=1

At the files=37 binary=1 step, any other Selenium Manager process gets this browser back from the unlocked check, even though only 36 of its 349 files are in place (the other file is the lock).

Lingua principale
Java
Stelle
34.6k
Fork
8.7k
Merge medio
1g 16h
PR unite (30g)
107

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SeleniumHQ/selenium

Tutte le issue di SeleniumHQ/selenium

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.