mvysny / karibu-testing

Vaadin Server-Side Browserless Containerless Unit Testing
Apache License 2.0
111 stars 14 forks source link

_get() method giving OutOfMemoryError #164

Closed avdhootu27 closed 6 months ago

avdhootu27 commented 6 months ago

I am using karibu-testing-v10 with vaadin 14.11, spring boot 2.7, java 11 Functions like _get(), _click() are giving Java heap space OutOfMemoryError.

I tried all types of calls to _get method but nothing worked.

Screenshot 2024-03-11 at 9 56 30 AM

e.g. If I am trying to navigate to a view which doesn't exist: UI.getCurrent().navigate('unknown-view'); It gets navigated to ErrorView (ErrorView is errorRoute). But when I try to check it with karibu: _get(ErrorView.class) then it gives OutOfMemoryError. I tried on IDE terminal and in device terminal but at both places same error is there. And when I am trying to check if the view attached or not by running UI.getCurrent().getChildren().findFirst().get() then I get object of ErrorView.class. It means the view is getting attached to UI but karibu _get method is not getting it and giving OutOfMemoryError.

I have no idea why I am getting OutOfMemoryError.

mvysny commented 6 months ago

Wow, that's quite unexpected. This could happen if there is a component with lots of children, or if the component hierarchy is very deep, or if there is a cycle in the component hierarchy. Or your JVM memory is almost spent and a small "pebble" is enough to trigger the OutOfMemoryError. Maybe you can add a breakpoint to LocatorKt.find():237 which doesn't stop JVM but rather prints the current component in stdout - maybe we can learn that there's a particular component causing this kind of behavior.

avdhootu27 commented 6 months ago

I can't find LocatorKt.find():237, I can see class LocatorKt.class but I have option only to decompile it in java, not in kotlin

mvysny commented 6 months ago

Can you reproduce this issue in a small project? If yes, can you attach a zip of the project here?

avdhootu27 commented 6 months ago

Oh I forgot to mention here that it got solved. It was my mistake, as you rightly told it can occur if there is a component with lots of children and I was having a function which was mistakenly calling itself and was creating infinite children. So I am closing this issue. Thanks.