microsoft / playwright-java

Java version of the Playwright testing and automation library
https://playwright.dev/java/
Apache License 2.0
1.16k stars 209 forks source link

[Bug]: STACKOVERFLOW Exception in Playwright code #554

Closed abhinav-kipper closed 3 years ago

abhinav-kipper commented 3 years ago

Playwright version

1.12.1

Operating system

Windows

What browsers are you seeing the problem on?

Chromium

Other information

Java version - 8

What happened? / Describe the bug

I am using playwright to navigate to a page and then print pdf. The code works fine for initial requests but after sometime playwright code stops working as it starts throwing stackoverflow exception for every request. If I restart my application, the issue gets resolved.

Why playwright keeps throwing Stackoverflow exception? It keeps recursing over same code again and again until it throws STACKOVERFLOW EXCEPTION

Code snippet to reproduce your bug

No response

Relevant log output

Request processing failed; nested exception is java.util.concurrent.ExecutionException: java.lang.StackOverflowError] with root cause
java.lang.StackOverflowError: null
    at java.text.DateFormatSymbols.getInstance(DateFormatSymbols.java:340)
    at java.util.Calendar.getDisplayName(Calendar.java:2110)
    at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1125)
    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:966)
    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936)
    at java.text.DateFormat.format(DateFormat.java:345)
    at ch.qos.logback.core.util.CachingDateFormatter.format(CachingDateFormatter.java:48)
    at ch.qos.logback.classic.pattern.DateConverter.convert(DateConverter.java:61)
    at ch.qos.logback.classic.pattern.DateConverter.convert(DateConverter.java:23)
    at ch.qos.logback.core.pattern.FormattingConverter.write(FormattingConverter.java:36)
    at ch.qos.logback.core.pattern.CompositeConverter.convert(CompositeConverter.java:24)
    at ch.qos.logback.core.pattern.FormattingConverter.write(FormattingConverter.java:36)
    at ch.qos.logback.core.pattern.PatternLayoutBase.writeLoopOnConverters(PatternLayoutBase.java:115)
    at ch.qos.logback.classic.PatternLayout.doLayout(PatternLayout.java:141)
    at ch.qos.logback.classic.PatternLayout.doLayout(PatternLayout.java:39)
    at ch.qos.logback.core.encoder.LayoutWrappingEncoder.encode(LayoutWrappingEncoder.java:115)
    at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:230)
    at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:102)
    at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:84)
    at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:51)
    at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)
    at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257)
    at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
    at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
    at ch.qos.logback.classic.Logger.info(Logger.java:579)
    at html2pdf.handlers.PageHandler.lambda$runScriptOnPageLoad$6(PageHandler.java:120)
    at com.microsoft.playwright.impl.ListenerCollection.notify(ListenerCollection.java:35)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:170)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.FrameImpl.evaluateImpl(FrameImpl.java:299)
    at com.microsoft.playwright.impl.PageImpl.lambda$evaluate$22(PageImpl.java:659)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.PageImpl.evaluate(PageImpl.java:659)
    at com.microsoft.playwright.Page.evaluate(Page.java:2302)
    at html2pdf.handlers.PageHandler.lambda$runScriptOnPageLoad$6(PageHandler.java:121)
    at com.microsoft.playwright.impl.ListenerCollection.notify(ListenerCollection.java:35)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:170)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.FrameImpl.evaluateImpl(FrameImpl.java:299)
    at com.microsoft.playwright.impl.PageImpl.lambda$evaluate$22(PageImpl.java:659)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.PageImpl.evaluate(PageImpl.java:659)
    at com.microsoft.playwright.Page.evaluate(Page.java:2302)
    at html2pdf.handlers.PageHandler.lambda$runScriptOnPageLoad$6(PageHandler.java:121)
    at com.microsoft.playwright.impl.ListenerCollection.notify(ListenerCollection.java:35)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:170)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.FrameImpl.evaluateImpl(FrameImpl.java:299)
    at com.microsoft.playwright.impl.PageImpl.lambda$evaluate$22(PageImpl.java:659)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.PageImpl.evaluate(PageImpl.java:659)
    at com.microsoft.playwright.Page.evaluate(Page.java:2302)
    at html2pdf.handlers.PageHandler.lambda$runScriptOnPageLoad$6(PageHandler.java:121)
    at com.microsoft.playwright.impl.ListenerCollection.notify(ListenerCollection.java:35)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:170)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.FrameImpl.evaluateImpl(FrameImpl.java:299)
    at com.microsoft.playwright.impl.PageImpl.lambda$evaluate$22(PageImpl.java:659)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.PageImpl.evaluate(PageImpl.java:659)
    at com.microsoft.playwright.Page.evaluate(Page.java:2302)
    at html2pdf.handlers.PageHandler.lambda$runScriptOnPageLoad$6(PageHandler.java:121)
    at com.microsoft.playwright.impl.ListenerCollection.notify(ListenerCollection.java:35)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:170)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.FrameImpl.evaluateImpl(FrameImpl.java:299)
    at com.microsoft.playwright.impl.PageImpl.lambda$evaluate$22(PageImpl.java:659)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.PageImpl.evaluate(PageImpl.java:659)
    at com.microsoft.playwright.Page.evaluate(Page.java:2302)
    at html2pdf.handlers.PageHandler.lambda$runScriptOnPageLoad$6(PageHandler.java:121)
    at com.microsoft.playwright.impl.ListenerCollection.notify(ListenerCollection.java:35)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:170)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.FrameImpl.evaluateImpl(FrameImpl.java:299)
    at com.microsoft.playwright.impl.PageImpl.lambda$evaluate$22(PageImpl.java:659)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.PageImpl.evaluate(PageImpl.java:659)
    at com.microsoft.playwright.Page.evaluate(Page.java:2302)
    at html2pdf.handlers.PageHandler.lambda$runScriptOnPageLoad$6(PageHandler.java:121)
    at com.microsoft.playwright.impl.ListenerCollection.notify(ListenerCollection.java:35)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:170)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.RouteImpl.resumeImpl(RouteImpl.java:76)
    at com.microsoft.playwright.impl.RouteImpl.lambda$resume$1(RouteImpl.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
    at com.microsoft.playwright.impl.RouteImpl.resume(RouteImpl.java:47)
    at com.microsoft.playwright.Route.resume(Route.java:162)
    at com.microsoft.playwright.impl.PageImpl.handleEvent(PageImpl.java:198)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:248)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
    at com.microsoft.playwright.impl.FrameImpl.evaluateImpl(FrameImpl.java:299)
yury-s commented 3 years ago

Could it be that Page.evaluate call from at html2pdf.handlers.PageHandler.lambda$runScriptOnPageLoad$6(PageHandler.java:121) triggers another load event in the page and the handler gets called recursively? Can you share the code of PageHandler.java ?

mxschmitt commented 3 years ago

Closing as part of the triage process since it seemed stale or did not get enough upvotes in the past. Please create a new issue with a detailed reproducible or feature request if you still encounter issues.

yury-s commented 3 years ago

@abhinav-kipper I finally looked at the code that you shared. The problem is that your onLoad handler evaluates something in the page that triggers another load event which quickly leads to stackoverflow issue.

    ...
    private void runScriptOnPageLoad() {
        page.onLoad(p -> {
            ...
            p.evaluate(script + invokeScriptString);
        });
    }
    ...

Note that p.evaluate is blocking and if it triggers another load event it will be dispatched above on the same stack. You can easily fix this by using page.waitForLoadState similar to how you do it in waitForContentLoad:

    ...
    private void runScriptOnPageLoad() {
        page.waitForLoadState();
        ...
        p.evaluate(script + invokeScriptString);
    }
    ...

This should fix stack overflow issue, but still may be racy in case load event gets dispatched before runScriptOnPageLoad is called but that'd be a different issue. Please reopen this bug or file a new if the problem persists.

abhinav-kipper commented 3 years ago

Thanks a lot @yury-s for identifying the issue.

I just need to ask two questions -

  1. Were you also able to identify which piece of code is triggering load event again in p.evaluate() ? I was not able to find anything specific in DomManipulationScript.js .

  2. As per docs, page.waitForLoadState(); waits until load event and if load event is already dispatched it does not wait at all and code can continue. How will then racy condition can arise as p.evaluate() will be called only (once) after the load event?

This resolves when the page reaches a required load state, load by default. The navigation must have been committed when this method is called. If current document has already reached the required state, resolves immediately.

yury-s commented 3 years ago
  1. Were you also able to identify which piece of code is triggering load event again in p.evaluate() ? I was not able to find anything specific in DomManipulationScript.js .

No, sorry, the code snippet is quite long. You can try an bisect it as you are more familiar with that code. I also don't know what the page does and whether DOMManipulationScript.js may trigger any listeners in it.

2. As per docs, page.waitForLoadState(); waits until load event and if load event is already dispatched it does not wait at all and code can continue. How will then racy condition can arise as p.evaluate() will be called only (once) after the load event?

My statement was inaccurate. Adding for page.onLoad() is racy as it depends on whether the load event already fired, waitForLoadState is free of such flaw.