Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
How to fix downloads with `chrome.downloads` extensions' API getting automatically interrupted if download confirmation setting is ON?

Description

I am developing a small Chrome extension and needed to download a file off web. Here's how the script behaves:

  1. I initiate the download in my service_worker JS file (either on a command event or with no conditionals at all)
  2. The download starts
  3. The callback runs and receives an ID (which means download starts successfully)
  4. The download never completes (saveAs dialog never opens even if set to true)
  5. Upon analyzing the DownloadItem object for the returned ID, its status is found to be interrupted and its reason to be USER_CANCELED
  6. No errors are reported in either of the consoles -- the page's or the service_worker's -- or the extensions page
  7. chrome.runtime.lastError is undefined as well.

Current Config

  • downloads in the permissions
  • <all_urls> in host permissions (for debugging)

Observation

  • The download succeeds if:
    • Ask where to save each file before downloading setting is turned off and...
    • filename/saveAs isn't set in passed DownloadOptions

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!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!