October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk8 min

How to Set Inactivity Timeouts in Playwright MCP, Playwright, Selenium, and Puppeteer

Set the right timeout at the right layer: Playwright MCP’s idle lifecycle flag, Playwright operation limits, Selenium’s separate waits, and Puppeteer cleanup.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Inactivity timeout and operation timeout solve different problems. An operation timeout stops a navigation, script, or element search that takes too long. An inactivity timeout closes or disconnects a browser after your controller has stopped sending work. Configure the setting at the layer that owns the problem: use --idle-timeout for a Playwright MCP browser lifecycle, operation-specific timeout options for Playwright, and separate script, page-load, and implicit waits for Selenium. Puppeteer’s documented default wait timeout is also an operation limit, not an idle shutdown.

First, define what “inactivity” means

Before changing a number, decide which event should end the wait:

  • A slow operation: navigation, JavaScript execution, waiting for a selector, or locating an element has exceeded its allowed duration. The operation fails; the browser session normally remains available.
  • An idle browser: the controller has sent no work for a period and you want a server-launched browser to close or disconnect. This is a lifecycle policy.
  • Intentional cleanup: your job is finished and you want to release the session immediately. Call the framework’s close or quit method rather than waiting for a timeout.

These layers are not interchangeable. Setting a Playwright page timeout or a Selenium implicit wait does not make an inactive browser close.

Playwright MCP: set the browser’s idle lifecycle timeout

Playwright MCP documents an idle timeout for a headless browser launched by the MCP server. The default is one hour without tool calls. Set the duration with the server argument --idle-timeout=<milliseconds>.

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.

Choose the value and unit

The value is an integer number of milliseconds. For example, 15 minutes is 900000; two hours is 7200000. Use 0 to disable automatic idle closure.

Example MCP server configuration

Add the argument to the command or MCP client configuration that starts the Playwright MCP server:

playwright-mcp --idle-timeout=1800000

This example allows 30 minutes without tool calls. When the idle period expires, the server closes the headless browser it launched.

Modes with different defaults

By default, headed browsers and browsers attached through --cdp-endpoint or --extension are not closed automatically. An explicit --idle-timeout can be applied to any mode. That distinction matters when the browser is owned by another process: closing it may affect other work using the same connection.

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

What resets the timer?

The documented trigger is the absence of MCP tool calls. A tool call is activity at the MCP server boundary; time spent inside a long-running operation is not the same as a period after the controller has stopped sending work. Keep your client’s job scheduling and the server’s idle policy separate.

Playwright library code: bound operations, not idle sessions

When you use Playwright directly, configure the timeout for the operation that can stall. The Page API provides method-level timeout options and default-timeout setters on a page or browser context. Navigation has its own timeout setters. Many operations default to no timeout (0), while particular wait methods have their own defaults; a method-level value overrides the broader default.

Per-operation timeout

await page.goto('https://example.com', { timeout: 45_000, waitUntil: 'domcontentloaded' });
await page.locator('button.submit').click({ timeout: 10_000 });
await page.waitForSelector('[data-ready="true"]', { timeout: 20_000 });

Here, a failed navigation, click, or selector wait raises an operation error. It does not mean that an otherwise idle browser will be torn down.

Set defaults for a page or context

page.setDefaultTimeout(10_000);
page.setDefaultNavigationTimeout(45_000);

// Or apply defaults to every page in a context:
context.setDefaultTimeout(10_000);
context.setDefaultNavigationTimeout(45_000);

timeout: 0 disables the relevant operation timeout. Use that deliberately: an unbounded wait can leave workers occupied forever when a selector or network condition never occurs.

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

Close Playwright deliberately

await browser.close();

Put explicit cleanup in a finally block when possible. This makes resource release independent of operation timeout behavior.

Selenium: three operation timeouts and explicit session cleanup

Selenium’s WebDriver options expose separate limits for scripts, page loads, and implicit element lookup. A new WebDriver session’s documented defaults are:

Setting Scope New-session default Expiry result
Script timeout Asynchronous JavaScript execution 30,000 ms The script operation errors
Page-load timeout Navigation completion 300,000 ms The navigation operation errors or is interrupted according to the driver
Implicit wait Element-location calls across the session 0 ms An element lookup fails without the configured polling period

These are technical defaults documented for a new session, not a universal inactivity-shutdown timer.

Python example: configure each Selenium timeout

from selenium import webdriver
from selenium.webdriver.common.by import By

options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options)
try:
    driver.set_script_timeout(30)       # seconds
    driver.set_page_load_timeout(300)   # seconds
    driver.implicitly_wait(0)           # seconds; keep lookup immediate

    driver.get("https://example.com")
    title = driver.find_element(By.TAG_NAME, "h1").text
    print(title)
finally:
    driver.quit()

Use the unit expected by the Selenium binding: the Python setters above take seconds. Check the binding and driver version you deploy before copying values into another language.

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

Implicit versus explicit waits

An implicit wait applies globally to element-location calls. An explicit wait targets a condition and duration at a particular point:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 20)
button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.submit")))
button.click()

Selenium’s waiting guidance states: “Do not mix implicit and explicit waits.” Mixing them can produce unpredictable timing because each lookup can consume the implicit period inside the explicit poll loop. Prefer an implicit wait of zero and explicit waits for conditions whose readiness you understand, or use one consistent strategy for the whole test suite.

End the WebDriver session with quit

Selenium’s session guidance recommends quit to stop a session. Call it when the job is complete or in a finally block after a failure. Do not expect a page-load or element timeout to release the browser process.

Puppeteer: the default wait is an operation limit

Puppeteer’s Page API documents a 30-second default wait timeout and allows you to change it with Page.setDefaultTimeout. This controls waits such as selector and interaction waits; it is not evidence of automatic idle-browser closure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const browser = await puppeteer.launch();
const page = await browser.newPage();
try {
  page.setDefaultTimeout(20_000);
  await page.goto('https://example.com', { waitUntil: 'domcontentloaded', timeout: 45_000 });
  await page.waitForSelector('h1');
} finally {
  await browser.close();
}

If your service needs an idle policy with Puppeteer, implement it in your worker or process supervisor: record the time of the last accepted job, schedule a timer, and call browser.close() when the policy expires. Do not confuse that application timer with Puppeteer’s page wait setting.

Choosing a timeout policy

There is no safe cross-framework number. Select a duration from the slowest legitimate workload, resource limits, and the cost of leaving a browser alive.

For operations

  • Set navigation limits long enough for the target’s expected load and any required redirects.
  • Set selector or interaction waits around the maximum time the UI is expected to render after a known trigger.
  • Use a bounded timeout for third-party pages and catch the error so the worker can record the URL and continue or retry.

For idle lifecycle

  • Use a shorter idle timeout for bursty, disposable workers to reclaim memory and file descriptors.
  • Use a longer value when a human or agent pauses between MCP actions and reconnecting is expensive.
  • Use 0 only when another supervisor owns cleanup or the browser is intentionally long-lived; otherwise an abandoned session can persist indefinitely.

For retries and reliability

Retry only failures that are plausibly transient, such as a network reset. Do not blindly retry deterministic selector failures. Record whether the failure was an operation timeout, an idle shutdown, a browser crash, or an explicit session quit; those outcomes require different recovery.

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

Troubleshooting common timeout problems

“My Selenium implicit wait did not close the browser.”

That is expected. Implicit wait only affects element-location calls. Add an application-level idle timer or call driver.quit() when finished.

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

“Playwright still has a browser after the page timeout.”

A page or navigation timeout aborts that operation. Close the browser explicitly, or configure Playwright MCP’s --idle-timeout when the MCP server owns the browser lifecycle.

“The MCP browser closes while an agent is paused.”

Check whether the server-launched headless browser has reached its one-hour default or your configured value. Increase the millisecond value, set 0 to disable automatic closure, or keep the agent issuing tool calls within the intended window.

“An attached browser was not closed.”

Browsers in headed mode or attached through --cdp-endpoint or --extension are not closed automatically by default. Supply an explicit --idle-timeout if that behavior is appropriate, and verify that your process actually owns the browser.

“Selenium waits are taking far longer than expected.”

Look for an implicit wait combined with explicit waits. Remove the implicit wait or redesign the condition so only one waiting strategy controls the polling period.

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

“A timeout value has no effect.”

Confirm the scope and unit: a method-level Playwright timeout applies only to that call; Selenium Python setters use seconds; Playwright MCP expects milliseconds. Also check that a later default setter or per-call option is not overriding the value.

Measure and observe the behavior

Log the framework, browser mode, URL, operation name, configured timeout, start time, end time, and outcome. For an idle policy, also log the last tool call or job timestamp and the cleanup action. This lets you distinguish a genuinely slow page from a worker that stopped sending commands. Keep screenshots, traces, or HTML only when needed for diagnosis, because retained artifacts increase storage and privacy exposure.

Or skip the browser setup

If your goal is a reliable website image rather than interactive automation, ScreenshotNeo provides a single HTTP request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status.

Use the documented API examples at ScreenshotNeo’s documentation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. It supports full-page and element captures, device and viewport settings, retina scale, dark mode, PDF controls, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting, and an OpenAPI specification. Its parameter names are compatible with those used by other screenshot APIs.

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots; every feature is on every plan, and yearly billing gives two months free. Sign up for the free plan.

Frequently Asked Questions

Does zero always mean “wait forever” in browser automation?

No. In Playwright MCP, --idle-timeout=0 disables automatic idle closure. In Playwright operation settings, timeout: 0 disables that operation’s timeout. Interpret zero according to the specific API.

What should I record when a timeout occurs in CI?

Record the framework and version, timeout scope and unit, URL or operation, configured value, elapsed time, browser mode, and whether the session was later closed. This separates operation failures from lifecycle cleanup.

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

Can an external process enforce one idle policy for every framework?

Yes, but it must observe each worker’s activity and terminate or ask the framework to close the browser. Framework operation waits do not provide that cross-framework lifecycle policy.

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.

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.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair 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.