{"record":{"id":"477d0b390663a39f","repo":"microsoft/playwright","slug":"recording-requires-a-newer-version-of-playwright","errorCode":null,"errorMessage":"Recording requires a newer version of Playwright, please upgrade.","messagePattern":"Recording requires a newer version of Playwright, please upgrade\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/backend/context.ts","lineNumber":246,"sourceCode":"      await this._startPageVideo(page);\n  }\n\n  async stopVideoRecording(): Promise<string[]> {\n    if (!this._video)\n      return [];\n    const video = this._video;\n    for (const page of this._rawBrowserContext.pages())\n      await page.screencast.stop();\n    this._video = undefined;\n    return [...video.fileNames];\n  }\n\n  async startRecording() {\n    if (this._recordedActions)\n      throw new Error('Recording is already in progress.');\n    const browserContext = await this.ensureBrowserContext() as BrowserContextEx;\n    if (typeof browserContext._enableRecorder !== 'function')\n      throw new Error('Recording requires a newer version of Playwright, please upgrade.');\n    const recordedActions: string[] = [];\n    await browserContext._enableRecorder({\n      mode: 'recording',\n      recorderMode: 'api',\n      omitCallTracking: true,\n      language: languageGeneratorId(this.codegenLanguage()),\n    }, {\n      actionAdded: (page, action, code) => {\n        recordedActions.push(code);\n      },\n      actionUpdated: (page, action, code) => {\n        if (recordedActions.length)\n          recordedActions[recordedActions.length - 1] = code;\n        else\n          recordedActions.push(code);\n      },\n      signalAdded: (page, signal, code) => {\n        if (recordedActions.length && code)","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/microsoft/playwright/blob/312030cdcee20c006343e5f8420fe451b9aa6390/packages/playwright-core/src/tools/backend/context.ts#L228-L264","documentation":"Thrown when the underlying BrowserContext from the (possibly older) installed Playwright runtime does not expose the internal _enableRecorder hook that the tool backend needs. It is a version-skew guard: the tool backend package requires a matching or newer playwright-core runtime to run codegen recording.","triggerScenarios":"The MCP/tools backend talks to a browser context produced by an older playwright/playwright-core install where BrowserContext._enableRecorder does not exist (renamed or not yet added), so typeof check fails and the error is thrown.","commonSituations":"Global MCP server installed with an old playwright version while the project pins a newer @playwright/test; mixed installs via npx picking up a stale cached playwright; using playwright-core version older than the tools package expects.","solutions":["Upgrade playwright and playwright-core to the same latest version (npm i -D @playwright/test@latest)","Clear npx caches / reinstall so the MCP server bundles a matching runtime","Verify versions align: npm ls playwright-core"],"exampleFix":"# before\nnpx @playwright/mcp@latest   # backed by old playwright-core\n\n# after\nnpm i -D playwright@latest\nnpx playwright --version   # confirm matching version","handlingStrategy":"try-catch","validationCode":"// Check runtime compatibility before starting:\nimport { BrowserContext } from 'playwright-core';\nconst ok = typeof (ctx as any)._enableRecorder === 'function';\nif (ok) await backend.startRecording();","typeGuard":null,"tryCatchPattern":"try {\n  await backend.startRecording();\n} catch (e) {\n  if ((e as Error).message.includes('newer version of Playwright'))\n    throw new Error('Please upgrade playwright to use recording');\n  throw e;\n}","preventionTips":["Pin the MCP/tools package and playwright to compatible versions in one lockfile","Run npm ls playwright-core to detect duplicate/old copies","Upgrade all Playwright packages together, never partially"],"tags":["version-mismatch","playwright-core","recording","mcp"],"backgroundTag":"dependency-version-mismatch","analyzedSha":"312030cdcee20c006343e5f8420fe451b9aa6390","analyzedAt":"2026-08-27T19:20:32.228Z","contentChangedAt":"2026-08-27T19:20:32.228Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}