Skip to content

chore(protocol): split channel and dispatcher types#41321

Open
Skn0tt wants to merge 8 commits into
microsoft:mainfrom
Skn0tt:proto-dispatcher-split
Open

chore(protocol): split channel and dispatcher types#41321
Skn0tt wants to merge 8 commits into
microsoft:mainfrom
Skn0tt:proto-dispatcher-split

Conversation

@Skn0tt

@Skn0tt Skn0tt commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

  • generate separate channel and dispatcher protocol method surfaces
  • keep client calls free of progress while dispatcher methods receive Progress
  • split channel/dispatcher params, results, events, and initializers for typed channel references

Comment thread utils/generate_channels.js Outdated
eventTypes.push({eventName, eventType: paramsName});
const dispatcherParamsName = `${channelName}${titleCase(eventName)}DispatcherEvent`;
ts_types.set(paramsName, channelParameters.ts);
ts_types.set(dispatcherParamsName, dispatcherParameters.ts);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be fair to generate src/client/channels.d.ts and src/server/channels.d.ts as two separate files. This way we can also avoid duplicating all the code here in the generator, and instead call generate() function twice with different arguments.

Comment thread utils/generate_channels.js Outdated
}

channels_ts.push(` ${methodName}(params${method.parameters ? '' : '?'}: ${paramsName}, progress?: Progress): Promise<${resultName}>;`);
channelMethods.push(` ${methodName}(params${method.parameters ? '' : '?'}: ${channelParamsName}, signal?: AbortSignal): Promise<${channelResultName}>;`);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding signal should be done in another PR 😄

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Skn0tt Skn0tt force-pushed the proto-dispatcher-split branch from cb538f2 to d3a0b6e Compare June 16, 2026 12:54
@Skn0tt Skn0tt requested a review from dgozman June 16, 2026 12:54
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread packages/injected/src/injectedScript.ts Outdated
import type { Language } from '@isomorphic/locatorGenerators';
import type { AttributeSelectorPart, NestedSelectorBody, ParsedSelector, ParsedSelectorPart } from '@isomorphic/selectorParser';
import type * as channels from '@protocol/channels';
import type * as channels from '../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one using client channels instead of server channels? Even better - let's not use channels here, and declare an explicit type?

Comment thread packages/injected/src/storageScript.ts Outdated
import { parseEvaluationResultValue, serializeAsCallArgument } from '@isomorphic/utilityScriptSerializers';

import type * as channels from '@protocol/channels';
import type * as channels from '../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question.

Comment thread packages/isomorphic/trace/traceModel.ts Outdated
import type { ActionTraceEvent } from '@trace/trace';
import type { ActionEntry, ContextEntry, PageEntry } from './entries';
import type { StackFrame } from '@protocol/channels';
import type { StackFrame } from '../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one can also use a custom type, that's fine.

Comment thread packages/isomorphic/trace/traceUtils.ts Outdated
*/

import type { ClientSideCallMetadata, StackFrame } from '@protocol/channels';
import type { ClientSideCallMetadata, StackFrame } from '../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one as well.

Comment thread packages/isomorphic/expectUtils.ts Outdated

import { isRegExp, isString } from './rtti';
import type { ExpectedTextValue } from '@protocol/channels';
import type { ExpectedTextValue } from '../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file does not make sense anymore, because one caller wants to produce client-side options, and another wants to produce server-side options.

We can probably make all these random imports work by generating a single @protocol/channels with options/params, and two different client/server files for the actual FooBar interfaces. What do you think? Sorry for going back and worth.

*/

import type { SerializedError } from './channels';
import type { SerializedError } from './channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this file move! That said, we can inline it into packages/playwright-core/src/server/instrumentation.ts right away.

import type { CallMetadata, SdkObject } from './instrumentation';

export type { Progress } from '@protocol/progress';
export interface Progress {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic!

import type { FullConfig, Location } from '../../types/testReporter';
import type { config as commonConfig, FullConfigInternal, test as testNs } from '../common';
import type { StackFrame } from '@protocol/channels';
import type { StackFrame } from '../../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it surprising that we use the same StackFrame in so many places.

}
channels_ts.push(` undefined;`);
channels_ts.push(``);
function generateChannels(target) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this is just a big indentation change. Otherwise, it's hard to review 😄

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread packages/isomorphic/expectUtils.ts Outdated
Comment thread packages/isomorphic/trace/traceUtils.ts Outdated
Comment thread packages/isomorphic/platform.ts Outdated
import type { AndroidServerLauncherImpl } from '../androidServerImpl';
import type { Platform } from '@isomorphic/platform';
import type * as channels from '@protocol/channels';
import type * as channels from './channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - why channel and not channel_s_?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also like channels more, updated.

*/

import type { SerializedValue } from '@protocol/channels';
import type { SerializedValue } from '../client/channel'; // same type across client and server, either is fine

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also unfortunate, not sure what to do with it. Perhaps move to isomorphic? I don't think we can afford protocol depending on client or server.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I duplicated the SerializedValue type into here, what do you think?

Comment thread packages/playwright/src/matchers/expect.ts Outdated
Comment thread packages/trace-viewer/src/ui/callTab.tsx Outdated
Comment thread packages/trace/src/trace.ts Outdated
Comment thread tests/library/tracing.spec.ts Outdated
Comment thread utils/generate_channels.js
@Skn0tt Skn0tt requested a review from dgozman June 17, 2026 15:03
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [webkit] › mcp/cli-killall.spec.ts:42 › kill-all kills filtered dashboard pid @mcp-windows-latest-webkit

7353 passed, 1122 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

7 flaky ⚠️ [chromium-page] › page/page-request-continue.spec.ts:756 › propagate headers cross origin redirect after interception `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/beforeunload.spec.ts:130 › should support dismissing the dialog multiple times `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/popup.spec.ts:260 › should not throw when click closes popup `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/video.spec.ts:645 › screencast › should capture full viewport `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-page] › page/page-autowaiting-basic.spec.ts:58 › should await form-get on click `@webkit-ubuntu-22.04-node20`

39602 passed, 743 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants