microsoft/playwright-java

[Bug]: ArrayIndexOutOfBoundsException: arraycopy: length -1 is negative when calling Page. waitForResponse

kkocel opened this issue · 5 comments

Version

1.46.0

Steps to reproduce

  1. Write a code that calls
val someAjaxPattern = Regex(".*/foo.dwr").toPattern()
page.waitForResponse(someAjaxPattern) {
        myLocator.fill("${fieldToQuery.value}")
}

Expected behavior

I would expect this exception not to be thrown, or at least be wrapped in PlaywrightException

Actual behavior

Caused by: java.lang.ArrayIndexOutOfBoundsException: arraycopy: length -1 is negative
    at java.base/java.lang.System.arraycopy(Native Method)
    at java.base/java.util.ArrayList.shiftTailOverGap(ArrayList.java:828)
    at java.base/java.util.ArrayList.batchRemove(ArrayList.java:921)
    at java.base/java.util.ArrayList.removeAll(ArrayList.java:873)
    at com.microsoft.playwright.impl.ListenerCollection.remove(ListenerCollection.java:63)
    at com.microsoft.playwright.impl.WaitableEvent.dispose(WaitableEvent.java:56)
    at com.microsoft.playwright.impl.WaitableEvent.accept(WaitableEvent.java:46)
    at com.microsoft.playwright.impl.ListenerCollection.notify(ListenerCollection.java:44)
    at com.microsoft.playwright.impl.BrowserContextImpl.handleEvent(BrowserContextImpl.java:798)
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:292)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:211)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:118)
    at com.microsoft.playwright.impl.PageImpl.waitForEventWithTimeout(PageImpl.java:529)
    at com.microsoft.playwright.impl.PageImpl.waitForResponseImpl(PageImpl.java:1547)
    at com.microsoft.playwright.impl.PageImpl.lambda$waitForResponse$92(PageImpl.java:1539)
    at com.microsoft.playwright.impl.WaitForEventLogger.lambda$get$0(WaitForEventLogger.java:50)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.ChannelOwner.withLogging(ChannelOwner.java:89)
    at com.microsoft.playwright.impl.WaitForEventLogger.get(WaitForEventLogger.java:41)
    at com.microsoft.playwright.impl.ChannelOwner.withWaitLogging(ChannelOwner.java:82)
    at com.microsoft.playwright.impl.PageImpl.waitForResponse(PageImpl.java:1533)
    at com.microsoft.playwright.impl.PageImpl.waitForResponse(PageImpl.java:1524)
    at com.microsoft.playwright.Page.waitForResponse(Page.java:8070)

Additional context

No response

Environment

  • Docker Java image
  • Chromium

Can you share a minimal repro which we could run locally?

@yury-s I can, but it won't be functional since the page I use is internal. If it's not important I can create it anyway

@kkocel any updates? Does the bug still surface on 1.47 which has your fix included? Usually we keep bugs only open when we have a repro for it and we'd love to act on this one / close it.

@mxschmitt I will get back to you in a couple of days - I will un-suppress error logging and see if it still occurs

Closing as part of the triage process. Please file a new issue if it still persists after 1.47