diff --git a/packages/extension/src/ui/connect.tsx b/packages/extension/src/ui/connect.tsx index 3f8b52e86b83c..22c3ec632b69c 100644 --- a/packages/extension/src/ui/connect.tsx +++ b/packages/extension/src/ui/connect.tsx @@ -216,8 +216,8 @@ const ConnectApp: React.FC = () => { }; const VersionMismatchError: React.FC<{ extensionVersion: string }> = ({ extensionVersion }) => { - const readmeUrl = 'https://github.com/microsoft/playwright-mcp/blob/main/packages/extension/README.md'; - const chromeWebStoreUrl = 'https://chromewebstore.google.com/detail/playwright-mcp-bridge/mmlmfjhmonkocbjadbfplnigmagldckm'; + const readmeUrl = 'https://github.com/microsoft/playwright/blob/main/packages/extension/README.md'; + const chromeWebStoreUrl = 'https://chromewebstore.google.com/detail/playwright-extension/mmlmfjhmonkocbjadbfplnigmagldckm'; return (
Playwright client trying to connect requires newer extension version (current version: {extensionVersion}).{' '} diff --git a/packages/playwright/src/plugins/webServerPlugin.ts b/packages/playwright/src/plugins/webServerPlugin.ts index 2b8b9ca628b67..7c83dadad828f 100644 --- a/packages/playwright/src/plugins/webServerPlugin.ts +++ b/packages/playwright/src/plugins/webServerPlugin.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import net from 'net'; import path from 'path'; import colors from 'colors/safe'; @@ -20,7 +21,6 @@ import debug from 'debug'; import { ManualPromise } from '@isomorphic/manualPromise'; import { monotonicTime } from '@isomorphic/time'; import { raceAgainstDeadline } from '@isomorphic/timeoutRunner'; -import { createSocket } from '@utils/happyEyeballs'; import { isURLAvailable } from '@utils/network'; import { launchProcess } from '@utils/processLauncher'; @@ -210,13 +210,18 @@ export class WebServerPlugin implements TestRunnerPlugin { } async function isPortUsed(port: number): Promise { - try { - const socket = await createSocket('localhost', port); - socket.end(); - return true; - } catch { - return false; - } + const innerIsPortUsed = (host: string) => new Promise(resolve => { + const conn = net + .connect(port, host) + .on('error', () => { + resolve(false); + }) + .on('connect', () => { + conn.end(); + resolve(true); + }); + }); + return await innerIsPortUsed('127.0.0.1') || await innerIsPortUsed('::1'); } async function waitFor(waitFn: () => Promise, cancellationToken: { canceled: boolean }) { diff --git a/packages/utils/index.ts b/packages/utils/index.ts index 1e319ecd9afef..00fd5ca902cc2 100644 --- a/packages/utils/index.ts +++ b/packages/utils/index.ts @@ -23,7 +23,6 @@ export * from './debugLogger'; export * from './env'; export * from './eventsHelper'; export * from './fileUtils'; -export * from './happyEyeballs'; export * from './hostPlatform'; export * from './httpServer'; export * from './network'; diff --git a/tests/playwright-test/web-server.spec.ts b/tests/playwright-test/web-server.spec.ts index 992bfca8752f0..c171637bad76c 100644 --- a/tests/playwright-test/web-server.spec.ts +++ b/tests/playwright-test/web-server.spec.ts @@ -15,7 +15,6 @@ */ import type http from 'http'; -import type { AddressInfo } from 'net'; import path from 'path'; import { test, expect, parseTestRunnerOutput } from './playwright-test-fixtures'; import type { RunResult } from './playwright-test-fixtures'; @@ -313,12 +312,12 @@ test('should time out waiting for a server with url', async ({ runInlineTest }, expect(result.output).toContain(`Timed out waiting 300ms from config.webServer.`); }); -test('should be able to specify the baseURL without the server', async ({ runInlineTest }) => { +test('should be able to specify the baseURL without the server', async ({ runInlineTest }, { workerIndex }) => { + const port = workerIndex * 2 + 10500; const server = createHttpServer((req: http.IncomingMessage, res: http.ServerResponse) => { res.end('hello'); }); - await new Promise(resolve => server.listen(0, resolve)); - const port = (server.address() as AddressInfo).port; + await new Promise(resolve => server.listen(port, resolve)); const result = await runInlineTest({ 'test.spec.ts': ` import { test, expect } from '@playwright/test'; @@ -376,12 +375,12 @@ test('should be able to specify a custom baseURL with the server', async ({ runI await new Promise(resolve => server.close(resolve)); }); -test('should be able to use an existing server when reuseExistingServer:true', async ({ runInlineTest }) => { +test('should be able to use an existing server when reuseExistingServer:true', async ({ runInlineTest }, { workerIndex }) => { + const port = workerIndex * 2 + 10500; const server = createHttpServer((req: http.IncomingMessage, res: http.ServerResponse) => { res.end('hello'); }); - await new Promise(resolve => server.listen(0, resolve)); - const port = (server.address() as AddressInfo).port; + await new Promise(resolve => server.listen(port, resolve)); const result = await runInlineTest({ 'test.spec.ts': ` import { test, expect } from '@playwright/test'; @@ -409,12 +408,12 @@ test('should be able to use an existing server when reuseExistingServer:true', a await new Promise(resolve => server.close(resolve)); }); -test('should throw when a server is already running on the given port and strict is true', async ({ runInlineTest }) => { +test('should throw when a server is already running on the given port and strict is true', async ({ runInlineTest }, { workerIndex }) => { + const port = workerIndex * 2 + 10500; const server = createHttpServer((req: http.IncomingMessage, res: http.ServerResponse) => { res.end('hello'); }); - await new Promise(resolve => server.listen(0, resolve)); - const port = (server.address() as AddressInfo).port; + await new Promise(resolve => server.listen(port, resolve)); const result = await runInlineTest({ 'test.spec.ts': ` import { test, expect } from '@playwright/test'; @@ -440,13 +439,13 @@ test('should throw when a server is already running on the given port and strict await new Promise(resolve => server.close(resolve)); }); -for (const host of ['localhost', '127.0.0.1', '0.0.0.0', '::1']) { - test(`should detect the server if a web-server is already running on ${host}`, async ({ runInlineTest }) => { +for (const host of ['localhost', '127.0.0.1', '0.0.0.0']) { + test(`should detect the server if a web-server is already running on ${host}`, async ({ runInlineTest }, { workerIndex }) => { + const port = workerIndex * 2 + 10500; const server = createHttpServer((req: http.IncomingMessage, res: http.ServerResponse) => { res.end('hello'); }); - await new Promise(resolve => server.listen(0, host, resolve)); - const port = (server.address() as AddressInfo).port; + await new Promise(resolve => server.listen(port, host, resolve)); try { const result = await runInlineTest({ 'test.spec.ts': `