SpecFlowOSS / SpecFlow.Actions

BSD 3-Clause "New" or "Revised" License
57 stars 53 forks source link

Playwright instances not disposed until end of test run #122

Open johnboygit opened 1 year ago

johnboygit commented 1 year ago

https://github.com/SpecFlowOSS/SpecFlow.Actions/blob/3d0fcac2632473f142597faccf5f5a902c211716/Plugins/SpecFlow.Actions.Playwright/SpecFlow.Actions.Playwright/DriverInitialiser.cs#L62

In my SpecFlow Playwright project (mostly based on this one) I was seeing many node.js instances being created as the test suite ran.

The longer the test suite ran, the more instances that were being created. It wasn't until the end of the test run that they finally got disposed. Kick off a test run and view the Windows Task Manager to see.

I eventually traced the problem down to the line of code referenced above. The Playwright instance being created in the method was not being disposed after each scenario. I ended up modifying the code to expose the Playwright object and then dispose of it in the BrowserDirver.Dispose() method.

This problem was actually crashing our Linux build agent as it just kept running out of memory with masses of node.js instances.

I think this problem would be evident even with the unadulterated code here but perhaps someone could confirm. Hopefully this will save someone some time if they see Playwright memory usage getting out of control.