Skip to content

Add User-Agent with Playwright version to WebSocket requests - #1729

Closed
headlesstesting (headlesstesting) wants to merge 1 commit into
microsoft:masterfrom
headlesstesting:master
Closed

Add User-Agent with Playwright version to WebSocket requests#1729
headlesstesting (headlesstesting) wants to merge 1 commit into
microsoft:masterfrom
headlesstesting:master

Conversation

@headlesstesting

Copy link
Copy Markdown

This adds a Playwright: {version} user-agent header to WebSocket requests.

The reason why we think this PR is useful, is because for people using Playwright with our service, we can automatically determine the most compatible browser version by looking at the Playwright version string.

This adds a `Playwright: {version}` user-agent header to WebSocket requests.

@yury-s Yury Semikhatsky (yury-s) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The idea of passing version info in a header sgtm, I'm a bit concerned that this approach may not work if the client runs in a web page in the future.

@JoelEinbinder

Copy link
Copy Markdown
Contributor

Super interesting patch!

I agree with Yury that it would be nice if this was done in a web compatible way. From my research, it looks like document.cookie or the protocols parameter in the websocket constructor can be used for this. But neither option is very clean.

I'm also interested as to why you want the version number of playwright, but not which browser (firefox, webkit, chromium) that the user wants to connect to. Do you have some other way of distinguishing these connections?

@headlesstesting

headlesstesting (headlesstesting) commented Apr 10, 2020

Copy link
Copy Markdown
Author

Hi Joel Einbinder (@JoelEinbinder) , Yury Semikhatsky (@yury-s) : your comment about web compatibility makes sense.
Perhaps an alternative solution would indeed be to specify the version with the protocols parameter.

In Javascript:

var ws = new WebSocket('wss://example.com/path', ['Playwright v.x.y'])

Node:

this._ws = new WebSocket(URL, ['Playwright v.x.y'], {
      perMessageDeflate: false,
      maxPayload: 256 * 1024 * 1024, // 256Mb
});

I think this would be better than using document.cookie as that will not work with cross-domain requests?

The browser can be specified with the wsEndpoint, we provide several options:

  • wss://chrome.headlesstesting.com
  • wss://firefox.headlesstesting.com
  • ...

@aslushnikov

Copy link
Copy Markdown
Contributor

So what is the status of this? It hasn't been updated for a few months and doesn't seem to attract much interest...

headlesstesting (@headlesstesting) did you guys workaround this on your end?

@aslushnikov

Andrey Lushnikov (aslushnikov) commented Jun 25, 2020

Copy link
Copy Markdown
Contributor

I guess it's not relevant any more :)

@headlesstesting

Copy link
Copy Markdown
Author

Hi, we've not pursued this, perhaps at a later stage, we can come back with a new PR. Thanks!

Debbie O'Brien (debs-obrien) pushed a commit to debs-obrien/playwright that referenced this pull request Jun 10, 2025
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants