{"record":{"id":"26d8f974259c1d97","repo":"microsoft/playwright","slug":"timeout-options-timeout-ms-exceeded","errorCode":null,"errorMessage":"Timeout ${options.timeout}ms exceeded","messagePattern":"Timeout (.+?)ms exceeded","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/client/android.ts","lineNumber":97,"sourceCode":"        device?._didClose();\n      });\n\n      const result = await raceAgainstDeadline(async () => {\n        const playwright = await connection!.initializePlaywright();\n        if (!playwright._initializer.preConnectedAndroidDevice) {\n          connection.close();\n          throw new Error('Malformed endpoint. Did you use Android.launchServer method?');\n        }\n        device = AndroidDevice.from(playwright._initializer.preConnectedAndroidDevice!);\n        device._shouldCloseConnectionOnClose = true;\n        device.on(Events.AndroidDevice.Close, () => connection.close());\n        return device;\n      }, deadline);\n      if (!result.timedOut) {\n        return result.result;\n      } else {\n        connection.close();\n        throw new Error(`Timeout ${options.timeout}ms exceeded`);\n      }\n    });\n  }\n}\n\nexport class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel> implements api.AndroidDevice {\n  readonly _timeoutSettings: TimeoutSettings;\n  private _webViews = new Map<string, AndroidWebView>();\n  private _android: Android;\n  _shouldCloseConnectionOnClose = false;\n\n  static from(androidDevice: channels.AndroidDeviceChannel): AndroidDevice {\n    return (androidDevice as any)._object;\n  }\n\n  input: AndroidInput;\n\n  constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.AndroidDeviceInitializer) {","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/client/android.ts#L79-L115","documentation":"Thrown at the end of Android.connect() when raceAgainstDeadline reports timedOut=true, meaning the connect flow did not complete within options.timeout ms. The connection is closed and the error interpolates the requested timeout value.","triggerScenarios":"Calling `android.connect(endpoint, { timeout: 5000 })` against an unreachable, slow, or hung server. The deadline (monotonicTime + timeout) expires before initialization completes.","commonSituations":"Network latency, firewall blocking the WS port, server boot slow on first device enumeration, or timeout set lower than realistic handshake time. Note options.timeout of 0 means no timeout (deadline stays 0).","solutions":["Increase options.timeout to a realistic value for device enumeration.","Verify network reachability and that the Android server/port is open.","Retry with backoff if the failure is transient network flakiness."],"exampleFix":"// before\nconst device = await android.connect(endpoint, { timeout: 5000 });\n// after\nconst device = await android.connect(endpoint, { timeout: 60000 });","handlingStrategy":"retry","validationCode":"if (typeof options.timeout === 'number' && options.timeout < 10000)\n  console.warn('Android connect timeout <10s may be too short.');","typeGuard":null,"tryCatchPattern":"let lastErr;\nfor (let attempt = 0; attempt < 3; attempt++) {\n  try { return await android.connect(endpoint, { timeout: 60000 }); }\n  catch (e) {\n    lastErr = e;\n    if (!(e as Error).message.includes('Timeout')) throw e;\n  }\n}\nthrow lastErr;","preventionTips":["Size timeout to realistic handshake + device-enumeration latency.","Pre-check port reachability before connecting."],"tags":["android","connect","timeout","network"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}