I'm trying to create a Chrome ext that uses the chrome.downloads API. But it doesn't seem to... do anything. First time Chrome developing so I'm a bit unfamiliar with the environment, but no one else online seems to have this problem.
Searching for the issue, I've minimized my code to the following (using the jQuery code as a test download, but have tried many others):
chrome.downloads.download({
url: "https://code.jquery.com/jquery-3.6.0.min.js",
}, (dlid) => {
chrome.downloads.search({id: dlid}, (dl) => {
console.log(dl[0]);
});
});
This results in the following DownloadItem being printed in the console:
byExtensionId: [redacted for privacy]
byExtensionName: [redacted for privacy]
bytesReceived: 0
canResume: false
danger: "safe"
exists: true
fileSize: 0
filename: ""
finalUrl: "https://code.jquery.com/jquery-3.6.0.min.js"
id: 2675
incognito: false
mime: "application/javascript"
paused: false
referrer: ""
startTime: "2021-09-04T09:18:02.401Z"
state: "in_progress"
totalBytes: 0
url: "https://code.jquery.com/jquery-3.6.0.min.js"
But the file doesn't download, nor does anything happen to indicate even an attempt at it. Continued readings of the DownloadItem always gives the same result: stating that the download is in progress and 0 bytes has been downloaded so far. And nothing else on my system gives any indication that the file is being downloaded. But never does it result in any errors - instead it just sits seemingly idling.
Here's what I've ruled out to be the cause so far:
- Permission is declared in
manifest.json:"permissions": [..., "downloads", ...]. Removing it and running the same code throws errors. - Context is correct, this is not run in a content script. Trying to do so throws errors.
- Playing around with any of the
DownloadOptionsparameters has no effect at all.DownloadOptions.saveAsopens no dialog, andDownloadOptions.filenamehas no effect on theDownloadItem.filenamewhich is always an empty string. - I've tried many other download targets, both different domains and different filetypes. The resulting
mimeparameter updates according to the URL extension, but otherwise it creates the same error-free perpetual idling. - I've even tried fake URLs with the same outcome - invalid URL syntaxes throws errors, but nonexistent URLs just gives the same idle result.
- There's no evident Internet connectivity issues with my system, and I don't use any proxy or VPN.
- Running it on another machine, albeit with the same Chrome user login and the same Internet connection. Same result.