Skip to content

PDF download timing out on Chromium > 127 #279

@brianclinkenbeard

Description

@brianclinkenbeard

After updating past Chromium 127, running RSpec tests on PDF downloads now uniformly time out. We use this somewhat popular helper code to yield the download after clicking a PDF link:

module DownloadHelpers
  TIMEOUT = 10
  PATH    = Capybara.save_path

  module_function

  def downloads
    Dir[PATH.join('*.{pdf,csv}')]
  end

  def download
    downloads.first
  end

  def download_content
    wait_for_download
    File.read(download)
  end

  def wait_for_download
    Timeout.timeout(TIMEOUT) do
      sleep 0.1 until downloaded?
    end
  end

  def downloaded?
    !downloading? && downloads.any?
  end

  def downloading?
    downloads.grep(/\.crdownload$/).any?
  end

  def clear_downloads
    FileUtils.rm_f(downloads)
  end
end

RSpec.configure do |config|
  config.include DownloadHelpers, type: :system

  config.before(:each, type: :system) do
    clear_downloads
  end
  config.after(:each, type: :system) do
    clear_downloads
  end
end

Waiting for a PDF download just hangs indefinitely. Watching with headless turned off, the PDF will never load in the new tab, however, trying this manually on a clean instance of Chromium will load the PDF perfectly. Perhaps an upstream regression with the CDP? Maybe also related: rubycdp/ferrum#457 (reply in thread)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions