If Puppeteer works with headless: true but times out with headless: false, identify exactly which operation is timing out before changing launch flags or increasing timeouts. A headed browser adds a display and windowing path, and can behave differently around GPU rendering, sandbox permissions, responsive layout, dialogs, and timing. Compare both runs with the same Puppeteer version, bundled browser, URL, profile, viewport, and network conditions; then fix the specific difference.
First, identify what timed out
“Puppeteer timed out” is not a single failure mode. A browser-start timeout means Chrome did not launch in time; a page.goto() timeout concerns navigation; a waitForSelector() timeout means the requested selector did not satisfy its condition in the frame being checked; and a test-runner timeout may expire even if Puppeteer is still working. Diagnose the operation, not just the mode.
Puppeteer documents a 30,000 ms default for selector waits. Navigation and page timeouts are configurable separately, and selector waits can also be configured individually (including with a timeout of 0, which disables that wait’s timeout). See the Page.waitForSelector API and the LaunchOptions API for the behavior of the version you use.
Label each asynchronous boundary
Log immediately before and after each important operation, along with its elapsed time and configured timeout. This shows whether the failure is in launch, navigation, a response wait, a selector or frame wait, a navigation triggered by a click, or the test assertion that wraps the whole scenario.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
const { performance } = require('node:perf_hooks');
async function timed(label, timeoutMs, fn) {
const start = performance.now();
console.log(`[start] ${label}; timeout=${timeoutMs}ms`);
try {
const result = await fn();
console.log(`[done] ${label}; elapsed=${Math.round(performance.now() - start)}ms`);
return result;
} catch (error) {
console.error(`[failed] ${label}; elapsed=${Math.round(performance.now() - start)}ms`);
throw error;
}
}
Use the wrapper for the operations you suspect rather than catching and suppressing an error. Preserve the original error and stack: they often identify which wait expired.
Compare headed and headless runs fairly
Make the two runs as similar as possible before attributing a difference to headed rendering. Use the same Puppeteer version and browser executable, URL, profile state, viewport, device scale factor, cookies, user agent, permissions, extensions, and network conditions. Record which values you cannot hold constant.
Puppeteer guarantees compatibility with its bundled browser; using a different executable is at-your-own-risk behavior. Check the launch options documentation before pinning or changing an executable. A separate Chrome installation can have different revisions, policies, or dependencies and make a mode comparison misleading.
Minimal mode comparison
const puppeteer = require('puppeteer');
async function run(headless) {
const browser = await puppeteer.launch({
headless,
// Set executablePath only when intentionally testing a specific browser.
args: [],
});
try {
const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 800, deviceScaleFactor: 1 });
const response = await page.goto('https://example.com', {
waitUntil: 'domcontentloaded',
timeout: 30000,
});
console.log({ headless, status: response?.status(), url: page.url() });
} finally {
await browser.close();
}
}
(async () => {
await run(true);
await run(false);
})().catch(error => {
console.error(error);
process.exitCode = 1;
});
Run one mode at a time if resource contention or concurrent profile use could affect results. Do not share a live Chrome profile between concurrent processes. For repeatable tests, give each run a writable, isolated user-data directory, or let Puppeteer create its normal temporary profile.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Make sure headed Chrome has a usable display
Headless execution does not require the same visible windowing path as headed execution. On a desktop, confirm that the session can create a browser window. On Linux CI, verify that a working X server is available; a virtual display such as Xvfb is commonly used when the runner has no physical display. Check that DISPLAY points to the intended server, and capture Chrome’s standard error so startup failures are visible.
Also verify that the browser can write to its profile and cache directories. A display that starts successfully does not rule out a profile permission error, a missing shared dependency, or a policy preventing Chrome from starting.
Sandbox and Linux policy
Puppeteer’s troubleshooting guide discusses Linux sandbox startup failures and Ubuntu AppArmor restrictions that can block user namespaces, as well as GPU setup. Inspect the browser error output and the host’s applicable policy rather than assuming every launch failure is a display problem. See Puppeteer’s troubleshooting guide.
The guide shows --no-sandbox only as a possible workaround for trusted content and warns: “Running without a sandbox is strongly discouraged.” Do not make it the default fix, especially when navigating untrusted pages. Prefer resolving the host permission or policy issue while retaining Chrome’s sandbox.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Separate navigation completion from application readiness
page.goto() returns the main resource response, including the last response after redirects. Log the response status and final page.url(); a resolved navigation does not prove the application reached the state your test needs. Conversely, a timeout waiting for a particular navigation condition does not necessarily mean the target page is unusable.
Inspect redirects, response status, and whether the expected application shell exists. Headed and headless runs may receive different content because of viewport, cookies, user agent, extensions, permissions, or timing. Puppeteer’s Page.goto API documents navigation behavior.
Wait for the application’s actual condition
Choose a condition tied to the next action: a stable selector, a particular response, a known URL change, or an in-page state predicate. Use the narrowest condition that establishes readiness for your test.
networkidle is not a universal readiness signal. Analytics, WebSockets, polling, and other long-lived connections can keep network activity going, while an idle network alone does not guarantee that a client-rendered view is ready. If the page deliberately maintains connections, wait for the relevant application state instead of extending the navigation timeout indefinitely.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Check selector visibility, frame, and page state
waitForSelector() waits for a matching element to appear in the frame where it is called. By default, presence is enough. With visible: true, the element also must not be hidden by display: none or visibility: hidden. Puppeteer’s API says the method “Waits for an element matching the given selector to appear in the frame.” See the Frame.waitForSelector documentation.
Test the selector in the right context
- The target may be in a child frame, not the main page. Log
page.frames().map(frame => frame.url()), identify the correct frame, and wait in that frame. - The element may be in a shadow DOM, which ordinary page-level selector assumptions may not reach.
- The page may render the element only after a click, consent action, or other event.
- The selector may match an element that exists but is hidden, detached, or replaced during a rerender.
- The headed page may be on a different branch because a modal, consent screen, responsive breakpoint, or authentication state changed what rendered.
Take a screenshot at the failure point and save the DOM. Compare what is visibly present with the selector and the frame being queried. If a click opens a popup or new page, listen for and inspect the new page; waiting on the original tab for the popup’s content will not work.
Set only the timeout that matches the operation
page.setDefaultNavigationTimeout(30000);
page.setDefaultTimeout(15000);
await page.goto('https://example.com', {
waitUntil: 'domcontentloaded',
timeout: 30000,
});
await page.waitForSelector('[data-test="ready"]', {
visible: true,
timeout: 15000,
});
These values are examples, not universal recommendations. Choose a bounded duration appropriate to the operation and environment. Raising all timeouts can hide a missing selector, wrong frame, or failed application state; setting a timeout to zero can leave a broken test waiting forever.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Collect artifacts at the failing milestone
Headed mode can reveal responsive breakpoints, hover or focus states, animations, consent dialogs, and GPU-dependent canvas behavior. Capture evidence in both modes at the same milestones so you can tell whether the page failed to load, followed another branch, or simply rendered differently.
Recommended Free Tools
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Attach diagnostic listeners
page.on('console', message => {
console.log(`[console:${message.type()}] ${message.text()}`);
});
page.on('pageerror', error => console.error('[pageerror]', error));
page.on('requestfailed', request => {
console.error('[requestfailed]', request.url(), request.failure()?.errorText);
});
page.on('response', response => {
if (response.status() >= 400) {
console.error('[http-error]', response.status(), response.url());
}
});
Before a wait likely to fail, note the time and operation. In the failure handler, save a screenshot and page HTML, and record the final URL and frame URLs. Keep the artifacts for the same point in each mode; comparing a headed screenshot taken before navigation with a headless screenshot taken after readiness will not isolate the cause.
Fix the cause, not the symptom
Once the evidence identifies the difference, make the smallest change that addresses it. Supply a functioning display server; fix profile or cache permissions; resolve the specific sandbox or AppArmor issue; use the bundled browser; target the correct frame; handle a modal or required event; or wait for the application’s real readiness signal. Keep the wait bounded and retain useful diagnostics on failure.
- Do not add
--no-sandboxreflexively. - Do not replace all operation-specific timeouts with a very large global value.
- Do not use arbitrary sleeps as a substitute for proving a state has occurred.
- Do not retry a selector endlessly without checking its frame, visibility, and page state.
Troubleshooting by symptom
| Symptom | Likely area to inspect | Useful next step |
|---|---|---|
| Chrome fails before a page opens | Display availability, browser stderr, profile/cache writability, sandbox permissions, Linux policy, or an executable mismatch | Confirm the display and writable directories; inspect the troubleshooting guide and use the bundled browser for a controlled comparison. |
goto() times out |
Navigation condition, slow or stalled main resource, redirect behavior, or long-lived page activity | Log the response and final URL when available; select a readiness condition that fits the application rather than defaulting to network idle. |
waitForSelector() times out but the page looks loaded |
Wrong selector, hidden element, child frame, shadow DOM, delayed event, or different application branch | Save screenshot and HTML, list frame URLs, and test the selector in the correct context. |
| Only headed mode shows the wrong layout or content | Viewport/device scale, focus or hover, modal state, cookies, user agent, extension, or GPU rendering | Match viewport and state, then compare screenshots and console/page errors at the same point. |
| The test reports a timeout after Puppeteer operations appear complete | Test-runner deadline, nested timeout, or an unawaited operation | Label the assertion and Puppeteer waits separately; align the outer test budget with the bounded operations it contains. |
Or skip the browser setup
If the task is to capture a website rather than test a browser interaction, ScreenshotNeo offers a one-request screenshot API; it can return PNG, JPEG, WebP, or PDF. Its capture flow accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response reports the page verdict and billing status in headers. It also provides an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. See ScreenshotNeo and its API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. A screenshot API is not a replacement for Puppeteer when you need to click through a workflow, inspect browser behavior, or assert application state; it is an alternative when the deliverable is the screenshot itself. Sign up for 1,000 free screenshots a month with no card.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Frequently Asked Questions
Does headless: false work in CI?
Yes, if the CI environment provides a usable display or virtual display and Chrome has the necessary permissions and writable directories. The exact setup depends on the runner and operating system.
Should I set waitForSelector timeout to zero?
That disables the selector wait’s timeout; it does not fix a selector or state mismatch and can leave a test waiting indefinitely.
Can I use a different Chrome executable to debug this?
You can, but Puppeteer guarantees compatibility with its bundled browser; another executable makes the comparison less controlled.
Quick Recap
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.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →

