Closed ruifigueira closed 4 days ago
1.48.2
npx playwright test --ui
Here is a test that catches the leakage (requires runUITest fixture from tests/playwright-test/ui-mode-fixtures.ts):
runUITest
tests/playwright-test/ui-mode-fixtures.ts
test('should not leak websocket connections', async ({ runUITest }) => { const { page } = await runUITest({ 'a.test.ts': ` import { test, expect } from '@playwright/test'; test('test', async () => {}); `, }); const [ws1] = await Promise.all([ page.waitForEvent('websocket'), page.getByTitle('Reload').click(), ]); await Promise.all([ page.waitForEvent('websocket'), page.getByTitle('Reload').click(), ]); await expect.poll(() => ws1.isClosed()).toBe(true); });
Existing WebSocket connection should close when reloading.
Existing WebSocket connections are kept open.
testServerConnection is never closed when a reload is performed:
testServerConnection
https://github.com/microsoft/playwright/blob/46321e5bf25225762a375514063c55bda130ec9e/packages/trace-viewer/src/ui/uiModeView.tsx#L111-L120
If existing connection is closed in reloadTests, the test above no longer fails:
reloadTests
const reloadTests = React.useCallback(() => { setTestServerConnection(prevConnection => { prevConnection?.close(); return new TestServerConnection(new WebSocketTestServerTransport(wsURL)); }); }, []);
System: OS: Windows 11 10.0.22631 CPU: (12) x64 13th Gen Intel(R) Core(TM) i5-1335U Memory: 12.87 GB / 31.66 GB Binaries: Node: 20.17.0 - ~\scoop\apps\nvm\current\nodejs\nodejs\node.EXE Yarn: 1.22.22 - ~\scoop\apps\yarn\current\bin\yarn.CMD npm: 10.8.2 - ~\scoop\apps\nvm\current\nodejs\nodejs\npm.CMD pnpm: 9.12.3 - ~\scoop\shims\pnpm.EXE IDEs: VSCode: 1.95.3 - C:\Users\rui.figueira\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD Languages: Bash: 5.2.37 - C:\Users\rui.figueira\scoop\shims\bash.EXE npmPackages: @playwright/test: ^1.48.2 => 1.48.2
True! Do you want to send a fix?
Version
1.48.2
Steps to reproduce
Here is a test that catches the leakage (requires
runUITest
fixture fromtests/playwright-test/ui-mode-fixtures.ts
):Expected behavior
Existing WebSocket connection should close when reloading.
Actual behavior
Existing WebSocket connections are kept open.
Additional context
testServerConnection
is never closed when a reload is performed:https://github.com/microsoft/playwright/blob/46321e5bf25225762a375514063c55bda130ec9e/packages/trace-viewer/src/ui/uiModeView.tsx#L111-L120
If existing connection is closed in
reloadTests
, the test above no longer fails:Environment