Our script can return the sometimes cryptic “Target closed” error. Knowing that the “target” is normally our browser, the context or tab that our script is controlling can help us close in on the cause of the issue. Example error message:Documentation Index
Fetch the complete documentation index at: https://checkly-422f444a-sync-playwright-reporter-changelog-v1-5-0.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Possible causes
- Obvious possible cause: the browser, context or tab is being closed at the wrong time in the script.
- Not-so-obvious possible cause: promises are not being handled correctly, e.g.:
- Forgetting an
awaitso that thebrowser.close()executes before your command has terminated. - Wrong foreach usage: forEach expects a synchronous function, so use a for-of loop if you are using
await.
Note that this list neither is nor aims to be complete: additional possible causes most likely exist for this error.
Bugs don’t stop at CI/CD. Why would Playwright? 
Sign up and start using Playwright for end-to-end monitoring with Checkly.