fix: prevent nc history race condition when running more than one request at once#830
Merged
pedroferreira1 merged 5 commits intomasterfrom Jan 28, 2026
Merged
Conversation
andreabadesso
approved these changes
Jan 28, 2026
pedroferreira1
commented
Jan 28, 2026
Comment on lines
-181
to
+184
| ncId: lastTx.ncId, | ||
| ncId, |
Member
Author
There was a problem hiding this comment.
The history of a nano returns also txs of other contracts that execute methods of this contract, so lastTx.ncId was a different of ncId in some of the txs.
tuliomir
approved these changes
Jan 28, 2026
src/sagas/nanoContract.js
Outdated
| log.debug('Halting processing for nano contract transaction history request while it is loading...'); | ||
| return; | ||
| // Determine request type: 'before' (newer txs), 'after' (older txs), or 'initial' (full reload) | ||
| let requestType = 'initial'; |
Contributor
There was a problem hiding this comment.
suggestion(non-blocking): Create a constant or enum for this hardcoded string
src/sagas/nanoContract.js
Outdated
| * @param {string} ncId Nano Contract ID | ||
| * @returns {Set<string>} | ||
| */ | ||
| function getLoadingSet(ncId) { |
Contributor
There was a problem hiding this comment.
suggestion(non-blocking): Rename to getLoadingLockSet and the variables that fetch from here to loadingLock.
It makes it easier to understand, since most other places with loading in this codebase refer to a component state related to a spinner for user feedback.
tuliomir
approved these changes
Jan 28, 2026
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.
Motivation
The nano contract history list shows duplicate transactions. One possibility is a race condition when loading the before history more than once, and we don't deduplicate the elements.
Deduplicating it is more expensive than having a lock to prevent concurrent calls. Below a better analysis of the scenario from claude.
Acceptance Criteria
Example of race condition