instructure/canvas-lms · warning

[YouTube Scan Retry] Timed out scan_id=#

Error message

[YouTube Scan Retry] Timed out scan_id=#{progress.id}, course_id=#{progress.context_id}

What it means

YoutubeMigrationService performs YouTube link scans with a bounded wait; when a scan exceeds its deadline, the service finalizes the Progress object with timeout results, marks it complete, and logs this warning. The scan did not finish in time, but the job ends cleanly instead of hanging.

Solutions

  1. Re-run the scan for the course once YouTube/network conditions are healthy
  2. Increase the scan timeout or add per-link timeouts so slow links don't consume the whole budget
  3. Check YouTube API availability/quota for the period the scan ran
  4. Batch very large courses into smaller scans to stay within the deadline

Example fix

// before
# one big scan with fixed timeout -> timeouts on large courses
service.scan(course)
// after
service.scan(course, batch_size: 50) # smaller batches, per-link timeouts
Defensive patterns

Strategy: retry

Validate before calling

# before scanning, cheaply count links to size the timeout budget
link_count = course.youtube_links.count
raise ScanBudgetExceeded if link_count > MAX_LINKS_PER_SCAN

Try / catch

begin
  YoutubeMigrationService.scan(course)
rescue Timeout::Error
  # or detect progress results[:timeout_at]
  schedule_rescan(course, smaller_batch: true)
end

Prevention

When it happens

Trigger: A YouTube scan tracked by a Progress record (progress.id) for a course (progress.context_id) runs past the scan's timeout threshold — e.g., many YouTube links to validate or YouTube API calls hanging — so the timeout branch sets results[:timeout_at], calls progress.complete!, and logs this message.

Common situations: Course migrations with hundreds of embedded YouTube links; YouTube API slowness or outages; network egress restrictions in the job container causing HTTP calls to hang until the deadline.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/9a29ebb347c99b25. Report an issue: GitHub.

Appendix: source

Thrown at app/services/youtube_migration_service.rb:838

    progress.set_results(results)

    call_external_tool(progress.context, progress.id)

    Rails.logger.info("[YouTube Scan Retry] Re-emitted Live Event for scan_id=#{progress.id}, course_id=#{progress.context_id}, retry_count=#{results[:retry_count]}")
  end

  def self.timeout_scan(progress)
    results = (progress.results || {}).dup
    results[:new_quizzes_scan_status] = "timeout"
    results[:error] = "Timed out waiting for New Quizzes scan results after 3 hours"
    results[:completed_at] = Time.now.utc
    results[:timeout_at] = Time.now.utc

    progress.set_results(results)
    progress.complete!

    Rails.logger.warn("[YouTube Scan Retry] Timed out scan_id=#{progress.id}, course_id=#{progress.context_id}")
  end
end

View on GitHub (pinned to 1c9f0bb801)