Poll Listener Logging "Ignored listener invocation" After Upgrading to V-24.6.0

After upgrading my Vaadin application from version 24.3.0 to 24.6.0, I started encountering the following log message whenever a modal dialog is opened:

“Ignored listener invocation for ui-poll event from the client side for an inert body element.”

This issue arises while I have a polling mechanism in place that updates a date-time display every second using a poll listener. The relevant code snippets are as follows:

private void updateDateTime() {
UI.getCurrent().access(
() → dateTime.setText(LocalDateTime.now().format(DateTimeFormatter.ofPattern(“yyyy-MM-dd HH:mm:ss”))));
}

private void registerDateTimePollListener() {
UI.getCurrent().setPollInterval(1000);
UI.getCurrent().addPollListener(e → updateDateTime());
}

The modal dialog is implemented in the following abstract class:
public abstract class GenericConfigEditor extends Dialog implements LocaleChangeObserver {
private static final long serialVersionUID = 7757638143891854498L;
protected FormLayout componentLayout;

protected Button btnSave = new Button(new Icon(VaadinIcon.CHECK));
protected Button btnClose = new Button(new Icon(VaadinIcon.CLOSE));
protected Binder<T> binder = new Binder<>();
protected Button helpButton = new Button(VaadinIcon.QUESTION_CIRCLE.create());

protected GenericConfigEditor() {
    setCloseOnEsc(false);
    setCloseOnOutsideClick(false);
    setResizable(false);
    setModal(true);
    setDraggable(true);
}

}

Steps to Reproduce:

  1. Upgrade Vaadin from version 24.3.0 to 24.6.0.
  2. Open a modal dialog while the date-time polling is active.
  3. Observe the log output for the message regarding ignored listener invocations.

Expected Behavior:

The poll listeners should continue to function properly and not log any ignored listener invocations when a modal dialog is opened.

Actual Behavior:

The log indicates that listener invocations are being ignored, which was not the case in previous versions.

Environment:

  • Vaadin Version: 24.6.0
  • Java Version: 21
  • Spring boot Version : 3.2.5

I would appreciate any insights or solutions regarding this issue, as it affects the logging and potentially the functionality of my application. This ticket format provides clear information about your issue, making it easier for others in the Vaadin community to understand and assist you effectively.

→ Change to false

Your thread would be better as GitHub issue. There are already some in /flow and /flow-components if I remember correctly.

Yes, we can set it to false, but if we do, users will be able to access the background elements. However, we do not want to allow access to those background elements.

Also take a look at this thread Vaadin update -> Many messages in logfile -> "Ignored listener invocation"

A workaround is to manually register the listener and make it inert allowed.

        ComponentUtil.addListener(ui, PollEvent.class, event -> {
            System.out.println("Poll event: " + event);
        }, DomListenerRegistration::allowInert);

@marcoc_753 I have tried with that approach:

private void updateDateTime() {
dateTime.setText(LocalDateTime.now().format(DateTimeFormatter.ofPattern(“yyyy-MM-dd HH:mm:ss”)));
}

private void registerDateTimePollListener() {
UI.getCurrent().setPollInterval(1000);
ComponentUtil.addListener(this, PollEvent.class, event → updateDateTime(), DomListenerRegistration::allowInert);
}
However, I am still encountering the same issue.

I just created a ticket for this.

1 Like

Works for me. However, the listener should be added to the UI, not to this.

ComponentUtil.addListener(UI.getCurrent(), PollEvent.class, event → updateDateTime(), DomListenerRegistration::allowInert);

I am still encountering the same issue. Could you please share your code? @marcoc_753

thanks @Leif

Did you remember to also remove the original poll listener? Could there be some other part of the application that adds another listener? Finally, check that the error message is still for the ui-poll event rather than some other event name.

1 Like
@Route("poll")
public class PollExampleView extends HorizontalLayout {

    private final Span dateTime = new Span();
    private Registration pollRegistration;

    public PollExampleView() {
        addAttachListener(event -> {
            UI ui = event.getUI();
            ui.setPollInterval(1000);
            pollRegistration = ComponentUtil.addListener(ui, PollEvent.class,
                    pollEvent -> updateDateTime(),
                    DomListenerRegistration::allowInert);
        });
        addDetachListener(event -> {
            pollRegistration.remove();
            event.getUI().setPollInterval(-1);
        });

        Button button = new Button("Open dialog", e -> {
            Dialog d = new Dialog("HEY");
            d.add(new Span("Modal dialog"));
            d.setModal(true);
            d.open();
        });
        add(button, dateTime);
    }

    private void updateDateTime() {
        dateTime.setText(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    }

I have implemented a workaround and it is working .

thanks @marcoc_753 @Leif