Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda