Before submitting#
Area#
apps/desktop
Steps to reproduce#
Put 30 copies of a small PDF in Downloads, invoice.pdf to invoice (29).pdf:
cd ~/Downloads && printf '%%PDF-1.4\n' > invoice.pdf && for i in $(seq 1 29); do cp invoice.pdf "invoice ($i).pdf"; done
Serve a page with an attachment named invoice.pdf:
node -e 'require("http").createServer((req, res) => req.url === "/invoice" ? (res.writeHead(200, { "content-type": "application/pdf", "content-disposition": "attachment; filename=invoice.pdf" }), res.end("%PDF-1.4\n")) : res.end("<a href=/invoice>Download invoice</a>")).listen(8123)'
Ask the agent to open http://127.0.0.1:8123 in the built-in Browser.
Wait 5 seconds after the agent's last action, so the click counts as yours, then click Download invoice.
Expected behavior#
invoice (30).pdf shows up in Downloads.
Actual behavior#
Nothing shows up in Downloads, most of the time. The desktop log has preview download copy failed with ENOENT, so the shared file was already gone when the desktop tried to copy it. The agent's copy on the server is fine.
Looks like a race. The server's saveDownload saves the agent's copy, then calls download.delete() on the shared file (since #18435). The desktop copies that same file into Downloads, and checks each invoice (n).pdf name first, so same-name files give the delete time to win.
I first hit this with a normal download, no same-name files. That was rare. Same-name files make it happen most of the time.
Impact#
Minor bug or occasional failure
Version or commit#
main at 89ba000739
Environment#
macOS 26.5.1, desktop app, Electron 44.10.1. Same on Linux (Debian 13 arm64, Electron 44.10.1 under Xvfb).
Logs or stack traces#
preview download copy failed
ENOENT: no such file or directory, copyfile
Screenshots, recordings, or supporting files#
before.mp4
Workaround#
No response