fix(junit): create a new Playwright when the previous launcher run closed it - #1988
Open
monkey (Develop-KIM) wants to merge 1 commit into
Open
monkey (Develop-KIM) wants to merge 1 commit into
monkey (Develop-KIM) wants to merge 1 commit into
Conversation
…osed it Surefire's rerunFailingTestsCount (and similar retry tooling) executes the launcher again in the same JVM and thread. The first run's PlaywrightRegistry has already closed every Playwright it created, but the ThreadLocal in PlaywrightExtension still holds one of them, so the rerun launches a browser on a closed connection and fails with "Playwright connection closed". Reuse the ThreadLocal instance only when it belongs to the current run's registry and create a fresh one otherwise. Fixes: microsoft#1751
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rerunFailingTestsCount(this repo's own CI uses it throughPW_MAX_RETRIES) runs the launcher again in the same JVM and thread. The first run'sPlaywrightRegistryhas already closed everyPlaywrightit created, but theThreadLocalinPlaywrightExtensionstill hands one of them out, so the rerun launches a browser on a closed connection and fails withPlaywright connection closed.ThreadLocalinstance only when it belongs to the current run's registry and creates a fresh one otherwise. Clearing theThreadLocalfromclose()would not reach other threads.AutoCloseable, which older JUnit versions never close, so there the firstPlaywrightjust leaks and the rerun reuses it.TestFixturesRerunrunsRerunFixturethrough the launcher twice on one thread and fails onmainwith the error above. That needsjunit-platform-launcher, which comes in through thejunit-bomso it followsjunit.version.Fixes #1751