You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Page.screenshot() can hang indefinitely, not respecting the timeout #1892
This is the same issue as microsoft/playwright#36702, which was logged on the JavaScript Playwright library last year. However, at my work we are running into the same issue with the Java library, so I am re-logging the issue here. Essentially, the issue is that sometimes the Page.screenshot() method hangs forever regardless of the timeout set when taking the screenshot. This is a regression because it is not reproducible in version 1.37.0, which is the version we were originally using, but is reproducible in version 1.52.0, which we upgraded to last year to address a security issue. It is also reproducible in the latest version, 1.58.0.
Run the main method in PlaywrightScreenshotIssue.java
You will probably see the program hang indefinitely in trying to take a screenshot after "Taking screenshot 1" is printed to the console. The expected behavior is either that taking the screenshot succeeds or a TimeoutError is thrown after the timeout (set to 1 second).
This is a somewhat big issue for us, because we use Playwright not for automation testing but instead as part of our application. We have a "screenshot service" microservice that uses Playwright to take screenshots for a niche business use case and have run into this issue a few times in production.
The example repo provided is able to consistently reproduce the issue by causing the webpage to not respond. Obviously at work we are not forcing a webpage to not respond and I don't believe the webpage is not responding when this issue happens. In the times that we've seen this at work, it basically always succeeds on retry (i.e. creating a new Playwright instance and trying to do the exact same thing that ran into the issue).
Expected behavior
Either that taking a screenshot succeeds or a TimeoutError is thrown after the timeout (set to 1 second) in the linked repo.
Actual behavior
Calling page.screenshot() hangs indefinitely, regardless of the timeout set.
Additional context
No response
Environment
Operating system: MacOS 15.7.3
CPU: Apple M1 MAX
Java version: OpenJDK 64-Bit Server VM Corretto-17.0.8.8.1
I was not able to reproduce the issue. With the original source the test passes. I reduced the timeout in the page to 10ms and I see the following error:
com.microsoft.playwright.TimeoutError: Error {
message='Timeout 1000ms exceeded.
name='TimeoutError
stack='TimeoutError: Timeout 1000ms exceeded.
at ProgressController.run (/private/var/folders/t3/_mbh6z155sz1cr7prkpn9lsh0000gn/T/playwright-java-12852728968604363953/package/lib/server/progress.js:86:28)
at PageDispatcher._runCommand (/private/var/folders/t3/_mbh6z155sz1cr7prkpn9lsh0000gn/T/playwright-java-12852728968604363953/package/lib/server/dispatchers/dispatcher.js:91:31)
at DispatcherConnection.dispatch (/private/var/folders/t3/_mbh6z155sz1cr7prkpn9lsh0000gn/T/playwright-java-12852728968604363953/package/lib/server/dispatchers/dispatcher.js:325:39)
}
Call log:
- - taking page screenshot
at com.microsoft.playwright.impl.WaitableResult.get(WaitableResult.java:52)
at com.microsoft.playwright.impl.WaitableRace.get(WaitableRace.java:46)
at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:138)
at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:137)
at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:124)
at com.microsoft.playwright.impl.PageImpl.screenshotImpl(PageImpl.java:1209)
at com.microsoft.playwright.impl.PageImpl.screenshot(PageImpl.java:1164)
Activity
yury-s commentedon Mar 5, 2026
I was not able to reproduce the issue. With the original source the test passes. I reduced the timeout in the page to 10ms and I see the following error: