{"record":{"id":"6648e01737f618a5","repo":"microsoft/playwright","slug":"path-expected-channel-names-tostring","errorCode":null,"errorMessage":"${path}: expected channel ${names.toString()}","messagePattern":"(.+?): expected channel (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/client/channelOwner.ts","lineNumber":244,"sourceCode":"    // which can cause jest to crash. Let's help it out\n    // by just returning the important values.\n    return {\n      _type: this._type,\n      _guid: this._guid,\n    };\n  }\n}\n\nfunction logApiCall(logger: Logger | undefined, message: string) {\n  if (logger && logger.isEnabled('api', 'info'))\n    logger.log('api', 'info', message, [], { color: 'cyan' });\n  debugLogger.log('api', message);\n}\n\nfunction tChannelImplToWire(names: '*' | string[], arg: any, path: string, context: ValidatorContext) {\n  if (arg._object instanceof ChannelOwner && (names === '*' || names.includes(arg._object._type)))\n    return { guid: arg._object._guid };\n  throw new ValidationError(`${path}: expected channel ${names.toString()}`);\n}\n\ntype ApiZone = {\n  apiName: string;\n  frames: channels.StackFrame[];\n  title?: string;\n  internal?: boolean;\n  reported: boolean;\n  userData: any;\n  stepId?: string;\n  error?: Error;\n};\n","sourceCodeStart":226,"sourceCodeEnd":257,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/client/channelOwner.ts#L226-L257","documentation":"Thrown by the marshalling validator tChannelImplToWire() when an argument expected to be a Channel (a Playwright remote object reference) is not a ChannelOwner of the right type. The validator checks `arg._object instanceof ChannelOwner` and that its _type is in the allowed names list ('*' accepts any); otherwise it raises a ValidationError naming the path and expected channel types.","triggerScenarios":"Passing null, undefined, a plain object, a wrong-type channel (e.g. a Page where a Frame channel is required), or an object from a different Playwright connection into any API whose parameter is declared as tChannel in the protocol.","commonSituations":"Cross-connection object passing (two browsers/connections in one process); stale references after a close/b navigation; serializing/deserializing objects that lose their _object binding; calling internal protocol methods directly.","solutions":["Pass a live object of the correct type from the same connection.","Verify the value is not null/undefined and was obtained from the current connection.","Use the public API rather than direct channel-passing helpers."],"exampleFix":"// before\nawait someApiCall({ frame: staleOrWrongObject });\n// after\nconst frame = page.mainFrame(); // correct type, same connection\nawait someApiCall({ frame });","handlingStrategy":"type-guard","validationCode":"function isLiveChannel(arg: any, type?: string): boolean {\n  return !!arg?._object\n    && arg._object instanceof (require('./channelOwner').ChannelOwner)\n    && (!type || arg._object._type === type);\n}\nif (!isLiveChannel(value, 'Frame'))\n  throw new Error('Expected a live Frame channel from the same connection.');","typeGuard":"function isChannelOwnerOf<T extends string>(arg: any, type: T): boolean {\n  return !!arg?._object && arg._object._type === type;\n}","tryCatchPattern":null,"preventionTips":["Never pass objects across separate Playwright connections.","Obtain channel arguments from the same browser/connection lifecycle that will use them."],"tags":["protocol","validation","channel","type-validation"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}