Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limit WebSocket message backlog on reconnection #5487

Conversation

petermakowski
Copy link
Contributor

@petermakowski petermakowski commented Jun 26, 2024

Done

  • Updated WebSocket reconnection logic to limit message backlog

QA steps

  • Connect to the application and verify WebSocket connection is established
  • Simulate a network interruption (e.g., disable/enable network connection)
  • Confirm WebSocket reconnects successfully
  • Check application logs to ensure no message flood occurs on reconnection
  • Perform several actions in quick succession after reconnection to test the buffer

Fixes

Fixes: https://bugs.launchpad.net/maas/+bug/2070304
https://warthogs.atlassian.net/browse/MAASENG-3433

Screenshots

N/A

Notes

This change introduces a maxEnqueuedMessages limit to prevent overwhelming the server with a backlog of messages upon WebSocket reconnection. The limit is set to 30, which accommodates the typical 5-25 messages generated on page load plus some buffer for additional user actions.

@webteam-app
Copy link

Signed-off-by: Peter Makowski <peter.makowski@canonical.com>
@petermakowski petermakowski force-pushed the fix-reconnect-ui-high-cpu-lp#2070304 branch from 95b23d5 to f1368e9 Compare June 26, 2024 08:50
@petermakowski petermakowski changed the title fix: high CPU usage on reconnect UI fix: limit WebSocket message backlog on reconnection Jun 26, 2024
@petermakowski petermakowski requested review from r00ta and ndv99 June 26, 2024 08:53
@petermakowski petermakowski marked this pull request as ready for review June 26, 2024 08:53
Copy link
Contributor

@ndv99 ndv99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's wait for Jacopo's review+approval before merging

@petermakowski petermakowski merged commit f796cc5 into canonical:main Jun 26, 2024
11 checks passed
@ndv99 ndv99 added Review: Core +1 MAAS core team have approved this in QA and removed Review: Core needed QA is required from the MAAS core team labels Jun 26, 2024
petermakowski added a commit to petermakowski/maas-ui that referenced this pull request Jun 26, 2024
- Update WebSocket reconnection logic to prevent overwhelming the server with a flood of queued messages when the connection is re-established.

Signed-off-by: Peter Makowski <peter.makowski@canonical.com>
petermakowski added a commit to petermakowski/maas-ui that referenced this pull request Jun 26, 2024
- Update WebSocket reconnection logic to prevent overwhelming the server with a flood of queued messages when the connection is re-established.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review: Code +1 Review: Core +1 MAAS core team have approved this in QA Review: QA +1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants