{"record":{"id":"eb7a48c228d55b2d","repo":"microsoft/playwright","slug":"timeout-params-timeout-ms-exceeded","errorCode":null,"errorMessage":"Timeout ${params.timeout}ms exceeded","messagePattern":"Timeout (.+?)ms exceeded","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/client/connect.ts","lineNumber":73,"sourceCode":"    if ((params as any).__testHookBeforeCreateBrowser)\n      await (params as any).__testHookBeforeCreateBrowser();\n\n    const playwright = await connection!.initializePlaywright();\n    if (!playwright._initializer.preLaunchedBrowser) {\n      connection.close();\n      throw new Error('Malformed endpoint. Did you use BrowserType.launchServer method?');\n    }\n    playwright.selectors = playwright.selectors;\n    browser = Browser.from(playwright._initializer.preLaunchedBrowser!);\n    browser._shouldCloseConnectionOnClose = true;\n    browser.on(Events.Browser.Disconnected, () => connection.close());\n    return browser;\n  }, deadline);\n  if (!result.timedOut) {\n    return result.result;\n  } else {\n    connection.close();\n    throw new Error(`Timeout ${params.timeout}ms exceeded`);\n  }\n}\n\nexport async function connectToEndpoint(parentConnection: Connection, params: channels.LocalUtilsConnectParams, timeout: channels.TimeoutOptions): Promise<Connection> {\n  const localUtils = parentConnection.localUtils();\n  const transport = localUtils ? new JsonPipeTransport(localUtils) : new WebSocketTransport();\n  const connectHeaders = await transport.connect(params, timeout);\n  const connection = new Connection(localUtils, parentConnection._instrumentation, connectHeaders);\n  connection.markAsRemote();\n  connection.on('close', () => transport.close());\n\n  let closeError: string | undefined;\n  const onTransportClosed = (reason?: string) => {\n    connection.close(reason || closeError);\n  };\n  transport.onClose(reason => onTransportClosed(reason));\n  connection.onmessage = message => transport.send(message).catch(() => onTransportClosed());\n  transport.onMessage(message => {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/client/connect.ts#L55-L91","documentation":"Thrown by connectToEndpoint when raceAgainstDeadline reports result.timedOut — the connection/handshake (transport.connect + initializePlaywright + browser materialization) did not complete before the deadline derived from params.timeout. The connection is force-closed and the configured timeout is surfaced verbatim.","triggerScenarios":"Calling browserType.connect({ wsEndpoint, timeout }) where any of these exceeds timeout: slow/lossy network to the remote server, server under heavy load, initializePlaymium/preLaunchedBrowser handshake stalled, DNS/TLS handshake delay, or the server is up but the browser subprocess (chromium) is slow to spawn. Also triggered by passing an extremely small timeout value.","commonSituations":"Connecting across regions or over VPN; server running on resource-constrained CI; a firewall that silently drops packets mid-handshake; default/low timeout used against a slow launchServer target; transient cloud flakiness.","solutions":["Increase the timeout: connect({ wsEndpoint, timeout: 60_000 }) or omit it to use the default (30s).","Verify the wsEndpoint is reachable from the client (curl/wscat the WebSocket URL) and that the server process is healthy.","Check server-side logs/CPU/memory — a slow browser spawn is usually the root cause, not the network.","If connecting repeatedly, add a small retry with backoff rather than one large timeout."],"exampleFix":"// before\nconst browser = await chromium.connect({ wsEndpoint, timeout: 5000 });\n\n// after\nconst browser = await chromium.connect({ wsEndpoint, timeout: 60_000 });","handlingStrategy":"retry","validationCode":"// Pre-flight reachability + pick a generous timeout before connect().\nimport net from 'node:net';\nimport { URL } from 'node:url';\n\nasync function hostReachable(wsEndpoint, ms = 3000) {\n  const u = new URL(wsEndpoint);\n  return await new Promise(res => {\n    const s = net.createConnection({ host: u.hostname, port: Number(u.port || 80) });\n    const t = setTimeout(() => { s.destroy(); res(false); }, ms);\n    s.on('connect', () => { clearTimeout(t); s.destroy(); res(true); });\n    s.on('error', () => { clearTimeout(t); res(false); });\n  });\n}\nif (!(await hostReachable(wsEndpoint))) throw new Error(`server unreachable: ${wsEndpoint}`);","typeGuard":null,"tryCatchPattern":"async function connectWithRetry(bt, wsEndpoint, attempts = 3, timeout = 60_000) {\n  let lastErr;\n  for (let i = 0; i < attempts; i++) {\n    try { return await bt.connect({ wsEndpoint, timeout }); }\n    catch (e) {\n      lastErr = e;\n      if (!/Timeout \\d+ms exceeded/.test(String(e?.message))) throw e;\n      await new Promise(r => setTimeout(r, 1000 * (i + 1)));\n    }\n  }\n  throw lastErr;\n}","preventionTips":["Set timeout proportional to expected cold-start latency (browser spawn can take seconds).","Health-check the server (TCP/HTTP) before connecting.","Co-locate client and server when latency is unpredictable."],"tags":["network","timeout","connection"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}