You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Attachment downloads fire FileDownloadedEvent twice on the first tab #6028
Clicking a link to an attachment (Content-Disposition: attachment) produces twoFileDownloadedEvents for one file in the first tab DownloadsWatchdog attaches to, and one in every other tab:
Download
First tab
Other tabs
zip attachment
2 (auto_download=False and True)
1
PDF attachment
2
1
inline PDF (no attachment)
1
1
These are counts from real downloads in headless Chrome. The repro below gives the same result 3 runs out of 3.
Why: both download paths report the same file. Chrome's own download goes through Browser.downloadWillBegin/downloadProgress (auto_download=False). The network path, Network.responseReceived → download_file_from_url, also treats the attachment as downloadable (auto_download=True). Nothing links the two. The network path only dedupes by URL, against itself.
Why only the first tab:attach_to_target returns early once the browser-level download listener exists, before _setup_network_monitoring. So only the first tab ever gets network monitoring. That early return is also why per-tab network monitoring can't simply be turned on yet: every tab would start firing twice. It came up in review on #6022, which leaves the early return alone for this reason. Open PR #6027 makes exactly that change.
Not a duplicate of #5657 or #5519: those fix a different double dispatch, between Chrome's completion event and the filesystem poller, plus partial .crdownload files. Here the second event comes from the network-detection path. #2842 reported the same symptom on 0.7.0 and was closed as fixed in 2025-09. In this case the second event carries auto_download=True, so it comes from the network path.
Happy to open a PR making one path the source of truth if that's wanted.
Activity