fix(api): fix setTargetBlockTemperature() race condition#21278
Open
fix(api): fix setTargetBlockTemperature() race condition#21278
setTargetBlockTemperature() race condition#21278Conversation
sfoster1
approved these changes
Apr 15, 2026
Member
sfoster1
left a comment
There was a problem hiding this comment.
Wow, that's gross. Good catch!
rclarke0
approved these changes
Apr 15, 2026
Contributor
rclarke0
left a comment
There was a problem hiding this comment.
nice, I think this placement makes sense
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes RESC-564
Overview
A race condition causes the PE
waitForBlockTemperature()to read stale thermocycler state before the PEsetTargetBlockTemperature()'s background task has updated it. This is most visible when calling the PAPIset_block_temperature()twice at the same temperature, first without a hold, then with one, causing the hold to be skipped entirely.For example
When the PAPI
set_block_temperature()is called, it dispatches two PE commands:The explicit wait can read the
hold_timevalue before the background task has sent the newM104command to the firmware, causing it to see stale data (ex.,hold_time=0) from the previous command and exit immediately.To fix, we can add a
wait_for_lock_release()toTaskHandlerand utilize it inwaitForBlockTemperature()before reading thermocycler state. This ensures the background task fromsetTargetBlockTemperature()has completed sending theM104command before the explicit wait reads the hold time.Test Plan and Hands on Testing
Ran the following minimal protocol on
edgeand then on this branch to confirm the fix:Changelog
set_block_temperature()that may cause the thermocycler not to respect thehold_timevalue before proceeding to the next protocol command.Review requests
Risk assessment