test('stress test: run electronApp.evaluate() over and over', async () => {
const app = getApp()
const iterations = 1000
for (let i = 0; i < iterations; i++) {
const displays = await app.evaluate(({ screen }) => screen.getAllDisplays())
expect(displays).toBeTruthy()
expect(displays.length).toBeGreaterThan(0)
}
})
Expected behavior
No errors
Actual behavior
When communicating with main or renderer processes, I regularly get errors similar to the following:
"context or browser has been closed"
"Promise was collected"
"Execution context was destroyed, most likely because of a navigation"
"Cannot read properties of undefined (reading 'getOwnerBrowserWindow')"
These errors seem to happen randomly. And they will also happen with methods like electronApplication.getBrowser(page) or page.evaluate()
Additional context
This seems to have started with the release of Electron 27 and has continued in subsequent versions.
I know that Electron support in Playwright is experimental. And I've been writing some workarounds for the electron-playwright-helpers library. But before I release the workarounds, I'd like to figure out what's happening.
I have yet to create a minimal reproduction that generates these errors nearly as reliably as my (maximal) application.
Version
1.49.0
Steps to reproduce
Expected behavior
No errors
Actual behavior
When communicating with main or renderer processes, I regularly get errors similar to the following:
These errors seem to happen randomly. And they will also happen with methods like
electronApplication.getBrowser(page)
orpage.evaluate()
Additional context
This seems to have started with the release of Electron 27 and has continued in subsequent versions.
I know that Electron support in Playwright is experimental. And I've been writing some workarounds for the
electron-playwright-helpers
library. But before I release the workarounds, I'd like to figure out what's happening.I have yet to create a minimal reproduction that generates these errors nearly as reliably as my (maximal) application.
Environment