Skip to content

fix(signature-timeout-alert): derive parse message with useMemo instead of setState-in-effect - #353

Merged
1 commit merged into
Goldii-locks:mainfrom
otsimaofficial:fix/signature-timeout-alert-set-state-in-effect
Aug 31, 2026
Merged

fix(signature-timeout-alert): derive parse message with useMemo instead of setState-in-effect#353
1 commit merged into
Goldii-locks:mainfrom
otsimaofficial:fix/signature-timeout-alert-set-state-in-effect

Conversation

@otsimaofficial

Copy link
Copy Markdown
Contributor

Problem

CI's Lint step has been failing on every merge to main since at least #283/#284/#287 (checked the last 5 CI runs on main — all red). The cause is ESLint's react-hooks/set-state-in-effect rule flagging SignatureTimeoutAlert.tsx: an effect that called setParseMessage(...) synchronously right after checking activeTransactionXdr.

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_skeleton issues (#275, #276, #278, #279) I'm opening alongside this one.

Fix

parseMessage is purely derived from activeTransactionXdr (parse it, capture the error message if parsing fails) — no external system, no subscription. Replaced the useState + useEffect pair with a single useMemo, computed synchronously during render instead of scheduling a second render via an effect. Behavior is unchanged; __tests__/signature_timeout_alert.test.tsx's waitFor assertion 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 --noEmit passes.
  • npm run build passes.
  • 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 clean main checkout with this change stashed out, so it's unrelated to this fix.

🤖 Generated with Claude Code

…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.
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

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., Closes #123), or by clicking a button below:

Issue Title
#276 Design empty list display views for loading_spinner_skeleton Link to this issue
#279 Handle mobile viewports navigation styling in loading_spinner_skeleton Link to this issue
#275 Implement responsive sizing layouts on loading_spinner_skeleton Link to this issue
#278 Incorporate CSS micro-animations on loading_spinner_skeleton elements Link to this issue

ℹ️ Learn more about linking PRs to issues

@godamongstmen897 godamongstmen897 closed this pull request by merging all changes into Goldii-locks:main in cd1848a Aug 31, 2026
Biokes pushed a commit to Biokes/escrow-frontend that referenced this pull request Aug 31, 2026
CI has been failing at the Install step, so no run has reached lint,
typecheck, tests or build in some time. Four separate problems were
hiding behind that.

1. npm ci could not run at all: package.json and package-lock.json were
   out of sync (missing typescript@4.9.5 and @noble/hashes@2.4.0). The
   lockfile is regenerated so `npm ci --ignore-scripts` resolves. No
   dependency versions changed - @stellar/freighter-api stays on 6.0.0.

2. WalletBadge.tsx held two complete implementations concatenated by a
   bad merge, with two `export default`s and an unclosed brace, so the
   file did not parse. Both prop shapes are genuinely live: Navbar drives
   the badge with isConnecting/providerName/networkMismatch, while the
   design-token call sites drive it with an explicit status. The merged
   component takes the union and dispatches on `status`, so all three
   test files (46 assertions) pass against one component.

3. Two identifiers had been lost from their modules - useToast in
   FreighterConnector and a `short()` address helper in Navbar. The
   latter is replaced by the existing formatAddress export.

4. Tests: @stellar/freighter-api is CommonJS and reaches the app through
   @creit.tech/stellar-wallets-kit, so every suite rendering a
   context-dependent component died on a named-export error. Both are
   now inlined for the dep optimizer. The multi-sig hook tests fed
   base64 of "aaaa..." to a real Stellar parser while claiming to parse
   "a well-formed envelope"; they now build and sign a real envelope.
   One loader test asserted before React had flushed a subscription
   update, and is wrapped in act().

Lint, typecheck, 1352 tests across 88 files, and build all pass. One
lint error remains in SignatureTimeoutAlert (setState in effect); it is
left alone because open PR Goldii-locks#353 fixes it properly with useMemo.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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