Skip to content

fix(app): queue notification refetch if mqtt topic update occurs while refetching #18694

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

Merged
merged 1 commit into from
Jun 20, 2025

Conversation

mjhuff
Copy link
Contributor

@mjhuff mjhuff commented Jun 20, 2025

Closes RABR-781

Overview

If MQTT informs the app that it should refetch a particular topic while the app is actively refetching that topic, the app doesn't perform an additional refetch after the first refetch completes. This creates a potential race condition.

To fix, the app always needs to refetch again if MQTT tells the app an update is available while the app is in the process of refetching.

This bug is most noticeable on the robot-server/runs/commands_links when the commands in question are extremely short lived commands such as comment commands. This protocol repros the issue rather readily:

from opentrons import protocol_api
# metadata
metadata = {
    'protocolName': "Let's Pause A Lot",
    'author': '',
    'description': '',
}
requirements = {
    "robotType": "Flex",
    "apiLevel": "2.22",
}
def run(protocol: protocol_api.ProtocolContext):
    tiprack1 = protocol.load_labware('opentrons_flex_96_tiprack_1000ul', 'C3')
    instrument = protocol.load_instrument('flex_1channel_1000', mount = 'left', tip_racks=[tiprack1])

    for i in range(1, 10):
        protocol.comment("                          ")
        protocol.comment("**************************")
        protocol.comment("         Incubation       ")
        protocol.comment("**************************")
        protocol.comment("                          ")

        protocol.pause(
            """Starting Detection incubation on Flex. Please add seal to plate.
            Heater-shaker incubation will begin afterwards."""
        )
        instrument.pick_up_tip(tiprack1["A1"])
        instrument.return_tip()

Test Plan and Hands on Testing

Reran the above protocol multiple times:

  • On the network tab, when the race condition would have occurred, the app correctly performed an additional refetch and fetched the latest command. Ex, if the latest command returned from an app fetch was a "comment" command, a command that persists for only milliseconds, the app would immediately refetch and be returned a "pause" command.
  • Previously, the bug would happen maybe 1/2 pause screens. With changes, the issue did not occur once after multiple protocol run-throughs.

Changelog

  • Fixed intervention modals on the desktop app/ODD not always appearing when the robot emits related commands.

Review requests

  • I'm targeting edge with these changes given the risk level, but let me know if we want them elsewhere. (After some convos, we are targeting 8.5 for this fix).

Risk assessment

low-med: This change is only additive. If anything in the app was dependent on stale data, this bug was still a race condition at the end of the day, and we would have visibly seen the unwanted behavior by now. It's still a networking change though, so there's inherent risk involved.

@mjhuff mjhuff requested a review from a team as a code owner June 20, 2025 16:21
@mjhuff mjhuff requested review from TamarZanzouri and removed request for a team and TamarZanzouri June 20, 2025 16:21
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

ah, way simpler than i thought (once we figure it out of course)

@mjhuff mjhuff requested a review from a team as a code owner June 20, 2025 17:16
@mjhuff mjhuff changed the base branch from edge to chore_release-8.5.0 June 20, 2025 17:16
@mjhuff mjhuff removed the request for review from a team June 20, 2025 17:16
Copy link

codecov bot commented Jun 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.

Project coverage is 28.75%. Comparing base (7737f6d) to head (4b7340e).
Report is 1 commits behind head on chore_release-8.5.0.

Files with missing lines Patch % Lines
app/src/resources/useNotifyDataReady.ts 0.00% 16 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                   @@
##           chore_release-8.5.0   #18694      +/-   ##
=======================================================
+ Coverage                24.40%   28.75%   +4.34%     
=======================================================
  Files                     3149     3246      +97     
  Lines                   263954   281999   +18045     
  Branches                 27270    29149    +1879     
=======================================================
+ Hits                     64428    81083   +16655     
- Misses                  199503   200893    +1390     
  Partials                    23       23              
Flag Coverage Δ
protocol-designer 21.51% <0.00%> (+2.80%) ⬆️
step-generation 5.43% <0.00%> (+1.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
app/src/resources/useNotifyDataReady.ts 0.00% <0.00%> (ø)

... and 799 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mjhuff mjhuff merged commit f97e240 into chore_release-8.5.0 Jun 20, 2025
63 of 64 checks passed
@mjhuff mjhuff deleted the app_fix-pause branch June 20, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants