Repository navigation
[BUG]: Mock issue on Playwright 1.49+ using MPTS #162
Description
Activity
- changed the title
[-][BUG]: Mock is not supported on Playwright 1.49+ using PTS[/-][+][BUG]: Mock is not supported on Playwright 1.49+ using MPTS[/+]on Dec 23, 2024 Hi,
We couldn't reproduce this issue from our end. Tried with simple test using route() and test has passed.Could you please provide a sample to repro the issue?
I've implemented a test with similar steps, but the issue is not happening here (sessionId
074d7a6b-906e-4d85-b5f1-5f7109290f31):test('generic mock test', async ({ page }) => { const searchString = 'hcura-qa'; const mockedName = 'Mocked Name'; await page.goto('https://gh-users-search.netlify.app/'); await page.route(`*/**/users/${searchString}`, async (route) => { const response = await route.fetch(); let body = await response.json(); body.name = mockedName; await route.fulfill({ status: 200, body: JSON.stringify(body), }); }); await page.getByTestId('search-bar').fill(searchString); await page.getByRole('button', { name: 'search' }).click(); await expect(page.getByRole('heading', { name: mockedName, level: 4 })).toBeVisible(); });For us, when running our app using MPT service under CI, the referred failure is happening on line "const response = await route.fetch();".
It is not happening when using our infrastructure (github runners), and it happens when running over MPT service, with Playwright 1.49+, and it is not reproducible locally, that's why we think the issue is likely related to MPT.
- changed the title
[-][BUG]: Mock is not supported on Playwright 1.49+ using MPTS[/-][+][BUG]: Mock issue on Playwright 1.49+ using MPTS[/+]on Dec 30, 2024 Hi Hugo Cura (@hcura-qa), from the initial error message shared, I see that the User-Agent indicates Windows operating system while you had mentioned that the client OS is Linux. I'm assuming you are running tests using some proxy server which is running on Windows.
- user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.33 Safari/537.36 - sec-ch-ua-platform: "Windows"Could you provide us with the below details which would help us investigate the issue further
- The previous version in which your test was working with Microsoft Playwright Testing Service
- Node version
- Playwright configuration file
- If you are using some http proxy or socksv5 in your tests
- Client-side channel logs (Channel logs might contain some secrets like url, auth tokens, etc. Feel free to remove them before sending the logs)
- You can get them by setting the environment variable
DEBUG=pw:channel* - You can send this via email to playwrighttesting@microsoft.com
- You can get them by setting the environment variable
HI Hugo Cura (@hcura-qa) , Gentle reminder if you got chance to look into above info.
Puneet Agarwal (@puagarwa) Siddharth Singha Roy (@Sid200026) We’ve successfully replicated the failure, but it’s now blocking an important initiative. Hugo Cura (@hcura-qa) has already reached out to the suggested contact via email. Could you please take a look at this as soon as possible? If the logs we’re sharing aren’t sufficient to identify the issue, feel free to schedule time tomorrow for further debugging.
Hello Puneet Agarwal (@puagarwa) Siddharth Singha Roy (@Sid200026),
This issue appears to be a regression in Playwright 1.49.1. It works as expected in version 1.48.2 but fails in both 1.49.1 and 1.50.0.
Could you please share an ETA for the fix?
Sent some more details on email thread, but here it is the stack trace for the failure if it helps to get this issue fixed.
Failing Logs (Playwright 1.49.1):
pw:socks [1adac760240d34ad3b591e21a9882973] <= connect error ECONNREFUSED pw:channel <EVENT {"guid":"jsonPipe@46fd59359b8b3d476e774013ee0ebc12","method":"message","params":{"message":{"id":9,"error":{"error":{"message":"Socks5 proxy rejected connection - ConnectionRefused","stack":"Error: Socks5 proxy rejected connection - ConnectionRefused\n at t.closeSocket (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:72542)\n at t.handleSocks5FinalHandshakeResponse (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:78259)\n at t.processData (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:71735)\n at t.onDataReceivedHandler (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:71205)\n at Socket.onDataReceived (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:69600)\n at Socket.emit (node:events:514:28)\n at addChunk (node:internal/streams/readable:324:12)\n at readableAddChunk (node:internal/streams/readable:297:9)\n at Readable.push (node:internal/streams/readable:234:10)\n at TCP.onStreamRead (node:internal/stream_base_commons:190:23)","name":"Error"}},"log":[" - → POST http://localhost:4000/rpc"," - user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.33 Safari/537.36"," - accept: */*"," - accept-encoding: gzip,deflate,br"," - Content-Type: application/json"," - content-length: 136"," - cookie: session=TOKEN"]}}} pw:channel <RECV {"id":9,"error":{"error":{"message":"Socks5 proxy rejected connection - ConnectionRefused","stack":"Error: Socks5 proxy rejected connection - ConnectionRefused\n at t.closeSocket (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:72542)\n at t.handleSocks5FinalHandshakeResponse (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:78259)\n at t.processData (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:71735)\n at t.onDataReceivedHandler (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:71205)\n at Socket.onDataReceived (/usr/src/app/Workers/BrowserPodWorker/mpt-playwright-server-1_49/node_modules/playwright-core/lib/utilsBundleImpl/index.js:35:69600)\n at Socket.emit (node:events:514:28)\n at addChunk (node:internal/streams/readable:324:12)\n at readableAddChunk (node:internal/streams/readable:297:9)\n at Readable.push (node:internal/streams/readable:234:10)\n at TCP.onStreamRead (node:internal/stream_base_commons:190:23)","name":"Error"}},"log":[" - → POST http://localhost:4000/rpc"," - user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.33 Safari/537.36"," - accept: */*"," - accept-encoding: gzip,deflate,br"," - Content-Type: application/json"," - content-length: 136"," - cookie: session=TOKEN"]}Reacted by Puneet AgarwalHi Miguel Oliveira (@miguelofbc) , We have identified the fix and its already available in alpha version to try out. Fix will be ported onto 1.50 and will be available early next week.
Hello Puneet Agarwal (@puagarwa)
Thanks for following up, that is good news! It seems to be passing now with "@playwright/test": "^1.51.0-alpha-2025-01-30". Could you please point me to the link for the PR with the fix?
So, the plan is to release playwright 1.50.1 next week to include the fix for this, is that correct?This is revert PR Revert "Reapply "fix(har timing): record connect timing for proxied connections" (#32855) (#33003)" by dgozman · Pull Request #34535 · microsoft/playwright which fixed the issue.
That’s correct. I will update you once 1.50.1 get released and service browsers get updated with patched version.
Hi Miguel Oliveira (@miguelofbc) ,
The issue is fixed in 1.50.1, please let us know if you face any issue.This problem was fixed, no related issues so far.
Describe the bug
After the Playwright update to version 1.49.0 (also tested with 1.49.1), the native Playwright mocking tool (
route()) is not working anymore when running using Microsoft Playwright Testing service (MPTS).The test using a mocked call is failing with the following error:
We suspect the issue might be caused with the recent architecture change related to Chromium headless, that can be found here: microsoft/playwright#33566
To Reproduce
Steps to reproduce the behavior:
route()Playwright's native method)Screenshots
N/A
Setup information (please complete the following information):
82601638-f67d-4a8c-95bb-dc2db38b6a2dAdditional context
The affected test has no issues when running against our Github runners infrastructure. This is a 100% reproducible issue using Microsoft Playwright Testing Service.