fix(signature-timeout-alert): derive parse message with useMemo instead of setState-in-effect - #353
Open
otsimaofficial wants to merge 1 commit into
Conversation
…ad of setState-in-effect CI's lint step has been red since Goldii-locks#283/Goldii-locks#284/Goldii-locks#287: ESLint's react-hooks/set-state-in-effect rule flags the effect that called setParseMessage synchronously right after checking activeTransactionXdr. The value is purely derived from activeTransactionXdr, so compute it with useMemo during render instead of scheduling a second render via an effect.
|
Hey @otsimaofficial! 👋 It looks like this PR isn't linked to any issue. If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g.,
|
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.
Problem
CI's Lint step has been failing on every merge to
mainsince at least #283/#284/#287 (checked the last 5CIruns onmain— all red). The cause is ESLint'sreact-hooks/set-state-in-effectrule flaggingSignatureTimeoutAlert.tsx: an effect that calledsetParseMessage(...)synchronously right after checkingactiveTransactionXdr.This isn't related to any specific feature — it's blocking a clean CI signal for every future PR, including a batch of
loading_spinner_skeletonissues (#275, #276, #278, #279) I'm opening alongside this one.Fix
parseMessageis purely derived fromactiveTransactionXdr(parse it, capture the error message if parsing fails) — no external system, no subscription. Replaced theuseState+useEffectpair with a singleuseMemo, computed synchronously during render instead of scheduling a second render via an effect. Behavior is unchanged;__tests__/signature_timeout_alert.test.tsx'swaitForassertion on the malformed-XDR case still passes (it now resolves on the first check instead of after an effect flush).Testing
npm run lint→ 0 errors (previously 1 error / 4 warnings; the 4 pre-existing unrelated warnings remain).npx tsc --noEmitpasses.npm run buildpasses.npm run test: full suite run: no failures traced to this file/change. The suite does have some pre-existing flakiness under load (a rotating subset of unrelated tests — multisig XDR fixtures, a couple of 5s test timeouts) that reproduces identically on a cleanmaincheckout with this change stashed out, so it's unrelated to this fix.🤖 Generated with Claude Code