-
Notifications
You must be signed in to change notification settings - Fork 698
[playwright-browser-tunnel] Seperate out tunnelBrowserConnection and createTunneledBrowser to remove playwright dependency from tunnelBrowserConnection #5609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TheLarkInn
merged 6 commits into
microsoft:main
from
anarmawala:fix/update-dependency-chat
Feb 11, 2026
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
93ddb34
Update Dependency chart while making sure the api remains the same
anarmawala b8623da
changelogs
anarmawala fe73bef
Update common/changes/@rushstack/playwright-browser-tunnel/fix-update…
anarmawala d612368
fix package.json
anarmawala 77d954d
no need to update vscode extension
anarmawala 6434b6c
manually update vscode extension version
anarmawala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
apps/playwright-browser-tunnel/src/tunneledBrowserConnection/ITunneledBrowser.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import type { Browser } from 'playwright-core'; | ||
|
|
||
| /** | ||
| * Disposable handle returned by {@link createTunneledBrowserAsync}. | ||
| * @beta | ||
| */ | ||
| export interface IDisposableTunneledBrowser { | ||
| /** | ||
| * The connected Playwright Browser instance. | ||
| */ | ||
| browser: Browser; | ||
| /** | ||
| * Async dispose method that closes the browser connection. | ||
| * Called automatically when using `await using` syntax. | ||
| */ | ||
| [Symbol.asyncDispose]: () => Promise<void>; | ||
| } |
37 changes: 37 additions & 0 deletions
37
apps/playwright-browser-tunnel/src/tunneledBrowserConnection/ITunneledBrowserConnection.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import type { LaunchOptions } from 'playwright-core'; | ||
|
|
||
| import type { BrowserName } from '../PlaywrightBrowserTunnel'; | ||
|
|
||
| export interface IHandshake { | ||
| action: 'handshake'; | ||
| browserName: BrowserName; | ||
| launchOptions: LaunchOptions; | ||
| playwrightVersion: string; | ||
| } | ||
|
|
||
| export interface IHandshakeAck { | ||
| action: 'handshakeAck'; | ||
| } | ||
|
|
||
| /** | ||
| * Disposable handle returned by {@link tunneledBrowserConnection}. | ||
| * @beta | ||
| */ | ||
| export interface IDisposableTunneledBrowserConnection { | ||
| /** | ||
| * The WebSocket endpoint URL that the local Playwright client should connect to. | ||
| */ | ||
| remoteEndpoint: string; | ||
| /** | ||
| * Dispose method that closes the WebSocket servers. | ||
| * Called automatically when using `using` syntax. | ||
| */ | ||
| [Symbol.dispose]: () => void; | ||
| /** | ||
| * Promise that resolves when the remote WebSocket server closes. | ||
| */ | ||
| closePromise: Promise<void>; | ||
| } |
52 changes: 52 additions & 0 deletions
52
apps/playwright-browser-tunnel/src/tunneledBrowserConnection/TunneledBrowser.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import type { Browser, LaunchOptions } from 'playwright-core'; | ||
| import playwright from 'playwright-core'; | ||
|
|
||
| import type { ITerminal } from '@rushstack/terminal'; | ||
| import { ConsoleTerminalProvider, Terminal } from '@rushstack/terminal'; | ||
|
|
||
| import type { BrowserName } from '../PlaywrightBrowserTunnel'; | ||
| import { DEFAULT_LISTEN_PORT } from './constants'; | ||
| import type { IDisposableTunneledBrowser } from './ITunneledBrowser'; | ||
| import type { IDisposableTunneledBrowserConnection } from './ITunneledBrowserConnection'; | ||
| import { tunneledBrowserConnection } from './TunneledBrowserConnection'; | ||
|
|
||
| /** | ||
| * Creates a Playwright Browser instance connected via a tunneled WebSocket connection. | ||
| * @beta | ||
| */ | ||
| export async function createTunneledBrowserAsync( | ||
| browserName: BrowserName, | ||
| launchOptions: LaunchOptions, | ||
| logger?: ITerminal, | ||
| port: number = DEFAULT_LISTEN_PORT | ||
| ): Promise<IDisposableTunneledBrowser> { | ||
| // Establish the tunnel first (remoteEndpoint here refers to local proxy endpoint for connect()) | ||
|
|
||
| if (!logger) { | ||
| const terminalProvider: ConsoleTerminalProvider = new ConsoleTerminalProvider(); | ||
| logger = new Terminal(terminalProvider); | ||
| } | ||
|
|
||
| const connection: IDisposableTunneledBrowserConnection = await tunneledBrowserConnection(logger, port); | ||
| const { remoteEndpoint } = connection; | ||
| // Append query params for browser and launchOptions | ||
| const urlObj: URL = new URL(remoteEndpoint); | ||
| urlObj.searchParams.set('browser', browserName); | ||
| urlObj.searchParams.set('launchOptions', JSON.stringify(launchOptions || {})); | ||
| const connectEndpoint: string = urlObj.toString(); | ||
| const browser: Browser = await playwright[browserName].connect(connectEndpoint); | ||
| logger.writeLine(`Connected to remote browser at ${connectEndpoint}`); | ||
|
|
||
| return { | ||
| browser, | ||
| async [Symbol.asyncDispose]() { | ||
| logger.writeLine('Disposing browser'); | ||
| await browser.close(); | ||
| // Dispose the tunnel connection after browser is closed | ||
| connection[Symbol.dispose](); | ||
| } | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
apps/playwright-browser-tunnel/src/tunneledBrowserConnection/constants.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| export const SUPPORTED_BROWSER_NAMES: Set<string> = new Set(['chromium', 'firefox', 'webkit']); | ||
| export const DEFAULT_LISTEN_PORT: number = 56767; |
8 changes: 8 additions & 0 deletions
8
apps/playwright-browser-tunnel/src/tunneledBrowserConnection/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| export { createTunneledBrowserAsync } from './TunneledBrowser'; | ||
| export { tunneledBrowserConnection } from './TunneledBrowserConnection'; | ||
|
|
||
| export type { IDisposableTunneledBrowser } from './ITunneledBrowser'; | ||
| export type { IDisposableTunneledBrowserConnection } from './ITunneledBrowserConnection'; |
10 changes: 10 additions & 0 deletions
10
...ges/@rushstack/playwright-browser-tunnel/fix-update-dependency-chat_2026-02-07-01-52.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@rushstack/playwright-browser-tunnel", | ||
| "comment": "Update dependency chart to not always require playwright", | ||
|
anarmawala marked this conversation as resolved.
Outdated
|
||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "@rushstack/playwright-browser-tunnel" | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.