Mark Oliver's World

Posted: 19/04/2023

Intermittent Playwright Exception

I have been getting this error intermittently in our Azure Devops based Playwright tests using a headless Chrome browser:

            Microsoft.Playwright.PlaywrightException: net::ERR_NETWORK_CHANGED Stack Trace:    at Microsoft.Playwright.Transport.Connection.InnerSendMessageToServerAsync[T](String guid, String method, Dictionary`2 dictionary) in /_/src/Playwright/Transport/Connection.cs:line 165    at Microsoft.Playwright.Transport.Connection.WrapApiCallAsync[T](Func`1 action, Boolean isInternal) in /_/src/Playwright/Transport/Connection.cs:line 471    at Microsoft.Playwright.Core.Page.ReloadAsync(PageReloadOptions options) in /_/src/Playwright/Core/Page.cs:line 684
            
          

We have been unable to figure out the problem, but after another round of googling, I came across this stackoverflow answer:

"The underlying issue one of my docker-compose setups having restart=always. Unfortunatly I had a bug causing a container to terminate and restart. This restart caused the network change. It is determinable by running docker ps and noticing the container restarted."

https://stackoverflow.com/questions/44678168/docker-and-chromium-neterr-network-changed/72292093#72292093

The problem is:

  • The UI that is being tested is running in Docker!
  • The systems services are run in Docker via a compose file!
  • This is a test environment!
  • Some of the containers in our deployment are not fully configured!
  • They are constantly restarting!

This is what is causing Docker to reset the network, and thus this error we are seeing.

An easy fix was to kill the bouncing Docker containers as they are not needed.

Problem solved (well its not consistent enough to know for sure, but Tweet me in a month and I will be able to confirm or not.)


Thanks for reading this post.

If you want to reach out, catch me on Twitter!

I am always open to mentoring people, so get in touch.