{"record":{"id":"45a7ceab91e417bb","repo":"microsoft/playwright","slug":"route-from-har-is-not-supported-in-thin-clients","errorCode":null,"errorMessage":"Route from har is not supported in thin clients","messagePattern":"Route from har is not supported in thin clients","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/client/browserContext.ts","lineNumber":410,"sourceCode":"    this._bindings.set(name, binding);\n    return DisposableObject.from(result.disposable);\n  }\n\n  async route(url: URLMatch, handler: network.RouteHandlerCallback, options: { times?: number } = {}): Promise<DisposableStub> {\n    this._routes.unshift(new network.RouteHandler(this._options.baseURL, url, handler, options.times));\n    await this._updateInterceptionPatterns({ title: 'Route requests' });\n    return new DisposableStub(() => this.unroute(url, handler));\n  }\n\n  async routeWebSocket(url: URLMatch, handler: network.WebSocketRouteHandlerCallback): Promise<void> {\n    this._webSocketRoutes.unshift(new network.WebSocketRouteHandler(this._options.baseURL, url, handler));\n    await this._updateWebSocketInterceptionPatterns({ title: 'Route WebSockets' });\n  }\n\n  async routeFromHAR(har: string, options: { url?: string | RegExp, notFound?: 'abort' | 'fallback', update?: boolean, updateContent?: 'attach' | 'embed', updateMode?: 'minimal' | 'full' } = {}): Promise<void> {\n    const localUtils = this._connection.localUtils();\n    if (!localUtils)\n      throw new Error('Route from har is not supported in thin clients');\n    if (options.update) {\n      await this.tracing._recordIntoHAR(har, null, options);\n      return;\n    }\n    const harRouter = await HarRouter.create(localUtils, har, options.notFound || 'abort', { urlMatch: options.url });\n    this._harRouters.push(harRouter);\n    await harRouter.addContextRoute(this);\n  }\n\n  private _disposeHarRouters() {\n    this._harRouters.forEach(router => router.dispose());\n    this._harRouters = [];\n  }\n\n  async unrouteAll(options?: { behavior?: 'wait'|'ignoreErrors'|'default' }): Promise<void> {\n    await this._unrouteInternal(this._routes, [], options?.behavior);\n    this._disposeHarRouters();\n  }","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/client/browserContext.ts#L392-L428","documentation":"Thrown by BrowserContext.routeFromHAR() when the connection's localUtils() is null, which happens in thin/remote clients. HAR routing requires the LocalUtils server-side object to parse and serve the HAR file; thin clients don't host it. The guard is `if (!localUtils)`.","triggerScenarios":"Calling `context.routeFromHAR('rec.har')` after connecting via BrowserType.connect() to a remote endpoint, or in playwright-client thin mode. localUtils() returns null because the LocalUtils object lives only on the host that owns the registry.","commonSituations":"Moving tests from local launch to a remote browser grid (Browserless, internal Selenium grid) without realizing HAR routing needs host-side support; mixing thin client with full client features.","solutions":["Run the browser locally (launch/launchPersistentContext) where localUtils is present.","On the remote server, ensure a full (non-thin) Playwright build is serving the connection.","Replace HAR routing with route() handlers that don't need localUtils."],"exampleFix":"// before\nconst browser = await playwright.chromium.connect(wsEndpoint);\nconst ctx = await browser.newContext();\nawait ctx.routeFromHAR('rec.har');\n// after\nconst browser = await playwright.chromium.launch();\nconst ctx = await browser.newContext();\nawait ctx.routeFromHAR('rec.har');","handlingStrategy":"type-guard","validationCode":"const localUtils = (context as any)._connection?.localUtils?.();\nif (!localUtils)\n  throw new Error('routeFromHAR requires a local (non-thin) connection.');","typeGuard":"function supportsHarRouting(ctx: any): boolean {\n  return !!ctx?._connection?.localUtils?.();\n}","tryCatchPattern":null,"preventionTips":["Prefer local launch when HAR routing is required.","Detect thin-client mode and degrade to route() handlers."],"tags":["har","routing","remote","thin-client"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}