Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
FREEDOM251

Freedom251 › Blog › Chrome

Go chromedp Screenshot Fails with “context deadline exceeded”: How to Find the Cause

By Freedom251 Team · · 6 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A context deadline exceeded error means an operation did not finish before its context deadline; it does not, by itself, show that screenshot capture is broken. In a chromedp workflow, first find which action times out: browser startup, navigation, waiting for a page element, or capturing the screenshot. Then troubleshoot that stage.

Find the first chromedp action that times out

Navigation and screenshot capture are separate actions in chromedp’s examples. Element screenshots also query the page and measure the matching node before asking Chrome to capture it. Label and time each stage so you can identify where the deadline occurs, rather than changing the output format or capture call first. chromedp package documentation · official examples · current screenshot implementation.

As an Amazon Associate I earn from qualifying purchases.

Runnable Go diagnostic example

This example logs elapsed time and wraps errors with the stage and URL. It uses a selector wait before capturing an element. Set the deadline to suit your browser startup and page behavior; the example does not establish a universally appropriate timeout.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/chromedp/chromedp"
)

func main() {
	url := "https://example.com"
	selector := "h1"

	// Choose a deadline appropriate to your environment and page.
	ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
	defer cancel()

	browserCtx, cancelBrowser := chromedp.NewContext(ctx)
	defer cancelBrowser()

	run := func(stage string, actions ...chromedp.Action) error {
		start := time.Now()
		err := chromedp.Run(browserCtx, actions...)
		log.Printf("stage=%s url=%s elapsed=%s err=%v", stage, url, time.Since(start), err)
		if err != nil {
			return fmt.Errorf("%s for %s: %w", stage, url, err)
		}
		return nil
	}

	if err := run("navigate", chromedp.Navigate(url)); err != nil {
		log.Fatal(err)
	}
	if err := run("wait for selector", chromedp.WaitVisible(selector)); err != nil {
		log.Fatal(err)
	}

	var elementPNG, viewportPNG []byte
	if err := run("element screenshot", chromedp.Screenshot(selector, &elementPNG)); err != nil {
		log.Fatal(err)
	}
	if err := run("viewport screenshot", chromedp.CaptureScreenshot(&viewportPNG)); err != nil {
		log.Fatal(err)
	}

	log.Printf("captured element=%d bytes viewport=%d bytes", len(elementPNG), len(viewportPNG))
}

The example captures both an element and the viewport to make their behavior easy to compare. Remove the capture you do not need. For production code, write the returned bytes to a file or process them in your application. If startup itself must be isolated more precisely, run and log browser initialization separately in your job architecture; the first logged failing action still narrows the investigation.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Understand which screenshot operation you are running

Operation What it captures Important distinction
chromedp.Screenshot(selector, ...) The first matching element It must find the node and obtain its geometry before capture. A missing or not-yet-ready element points you toward selector and readiness debugging.
chromedp.CaptureScreenshot(...) The current browser viewport It does not mean the entire page. The package documentation describes it as a screenshot of the current browser viewport.
chromedp.FullScreenshot(...) Content beyond the viewport This requests full-page capture. The current implementation uses PNG at quality 100 and JPEG for other quality values; that can affect output size and capture work, but the cited documentation does not establish it as a general cause of deadline errors.

References: package API documentation and screenshot implementation.

Troubleshoot the failing stage

If browser startup is failing

  • Check that the browser process starts and remains healthy. For a remote browser, verify that the configured endpoint is reachable.
  • Record whether Chrome or Chromium is launched locally, in a container, or on a remote host. Do not apply a container flag or browser workaround unless the evidence points to that environment-specific problem.
  • Check whether a parent job or request context is canceled before browser startup or work completes.

If navigation is failing

  • Inspect the target page’s response and redirect behavior, and check whether the browser can reach required network resources.
  • Review the readiness condition that follows navigation. If you need one known element, waiting for that element may be more relevant than waiting for the entire page to become network-idle. The appropriate condition depends on the page and capture task; there is no universal readiness strategy.
  • Do not modify screenshot encoding or format until you know navigation succeeded.

If the selector wait or element screenshot is failing

  • Confirm the selector matches the intended element on the final page, including after redirects or client-side rendering.
  • Check that the element becomes visible before the available deadline. Element capture queries the matching node and obtains its rectangle before issuing the capture request.
  • Try a viewport screenshot after the same page state. If the viewport works while the element operation does not, focus on selector matching, visibility, and element geometry.

If capture itself appears to be failing

  • Compare viewport capture with element capture using the same known page state; these operations do different work.
  • Try a minimal local page to reduce network and page-script variables, then compare with the target page and deployment environment.
  • Keep full-page capture distinct from viewport capture. Full-page capture requests more than the visible viewport, but the available sources do not show that it generally causes this error.

If the timeout or context ownership is unclear

  • Trace where each context is created and canceled. A child operation cannot outlive a canceled parent context.
  • Choose a deadline that accounts for browser startup and the target page’s behavior. The official example does not prescribe a fixed timeout value.
  • Log the stage, URL, elapsed time, and wrapped error for each action. The first action that returns the deadline is the best starting point for diagnosis.

Record versions and deployment details

When asking for help or comparing behavior, include the exact environment. A deadline can depend on how Chrome is launched and where it runs, and an old issue report is not evidence that a current release has the same defect.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • Go version from go version.
  • The selected chromedp module version.
  • Chrome or Chromium version.
  • Operating system and architecture.
  • Container image or host details, if applicable.
  • Whether the browser is local or remote, and the failing stage from your logs.

Historical reports illustrate why those details matter without establishing a current general bug. Issue #904, opened August 26, 2021, described a 30-second deadline in a DigitalOcean App Platform deployment with chromedp v0.7.4, Chrome 90, and Go 1.16; the report did not establish the failing stage or root cause. Issue #585, opened March 14, 2020, concerned intermittent blank or cut element screenshots with chromedp v0.5.3, Chrome 80, and Go 1.13.8. Issue #801, opened April 23, 2021, described a hang when Chrome failed to open during navigation, using chromedp v0.5.1 and Chrome 89. These are individual reports from older environments, not proof of present behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If you need a screenshot without managing a chromedp browser workflow, ScreenshotNeo offers a website screenshot API. One GET request returns an image or PDF; here is the cURL form for a WebP screenshot:

Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for authentication and request options. Cookie banners and more than 60 known consent platforms, newsletter popups, and chat widgets can be removed before capture, with each step configurable. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; responses identify the page verdict and billing status in headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots a month without a card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month—no card required.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does `context deadline exceeded` mean chromedp’s screenshot API is defective?

No. The error identifies an expired context deadline, not the action that failed. Check the first labeled stage that returns it.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

What details should I include when reporting the problem?

Provide Go, chromedp, and Chrome or Chromium versions; OS and architecture; local, container, or remote setup; and the first failing action with its elapsed time.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

ChromechromedpGoscreenshotsTroubleshooting

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.