Description
I am developing a small Chrome extension and needed to download a file off web. Here's how the script behaves:
- I initiate the download in my
service_workerJS file (either on a command event or with no conditionals at all) - The download starts
- The callback runs and receives an ID (which means download starts successfully)
- The download never completes (
saveAsdialog never opens even if set totrue) - Upon analyzing the
DownloadItemobject for the returned ID, itsstatusis found to beinterruptedand its reason to beUSER_CANCELED - No errors are reported in either of the consoles -- the page's or the service_worker's -- or the extensions page
chrome.runtime.lastErroris undefined as well.
Current Config
downloadsin the permissions<all_urls>in host permissions (for debugging)
Observation
- The download succeeds if:
Ask where to save each file before downloadingsetting is turned off and...filename/saveAsisn't set in passedDownloadOptions
But shouldn't the download work nonetheless?
Background.js
chrome.commands.onCommand.addListener((command) => {
const url = "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"; //random image
chrome.downloads.download({url, saveAs: true}, (id) => {
console.log(chrome.downloads.search({id}, (result) => {
console.log(result)
console.log(chrome.runtime.lastError)
}))
})
})
Any idea what's going on? Any help would be highly appreciated!