fix(listener): reject a modal request superseded by a newer one #520
All Vouch review confidence checks passed
Residual risk 0.34 = Change Risk (0.50) × (1 − Review Confidence (0.32)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 595 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 20% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.382
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #520"
general
weight: 0.35
github-actions[bot]
When a merchant calls
displayModalwhile an earlier modal request is still pending (a double click, or two widgets on one page), the earlier call never resolves or rejects. In@frak-labs/react-sdk,useDisplayModalanduseSendTransactionthen stayisPendingfor the rest of the page view, and anawaiton the first call hangs.Summary
The handler unsubscribed the earlier request from the modal store but never settled its
Deferred. The modal on screen emits to the newest request only, so nothing could settle the first promise.Now the newest request owns the UI, and the request it replaces is rejected with
-32603 "New modal request superseded previous request". That is the code and message shape the sharing-page handler already uses.-32603for an action that happened. On asendTransactionstep, a merchant that retries on error could then send twice.internalError.clientAbortedmeans "the user dismissed the modal" to SDK callers.Evidence
Unit tests (
handleDisplayModal.test.ts). The first commit adds them and fails on the current code. The second commit fixes it.Deleting each guard in the fix makes a test fail: the takeover settle, the
latestRequestcheck, and the settle on the no-steps path.Browser. A Playwright script in headless Chromium loads a merchant page with the real SDK CDN bundle and the built listener iframe, against a mocked backend and seeded session (no SST stack). Steps:
{ login: {}, final: { action: { key: "reward" } } }.| Case |
dev| This branch ||---|---|---|
| 2nd call 100 ms after the 1st | 1st pending forever | 1st rejects
-32603, 2nd modal shown, resolves on dismiss || 2nd call during a session refresh delayed 800 ms (gaps 100/400 ms, 3 runs each) | 1st pending forever | 1st rejects
-32603, only the 2nd's modal is ever shown, 2nd resolves on dismiss || User completes the 1st modal while the 2nd waits on a 1.5 s refresh (3 runs) | 1st resolves with its result | 1st resolves with its result, then the 2nd modal is shown and resolves on dismiss |
On a cold iframe with two calls in the same instant, the listener sometimes handles the second message first: both wait on the same lazy
import()of the modal module. One call is rejected and the other settles in every run; which one wins can vary.Typecheck, biome and
lint:commentsare clean.Merge Danger
Door: two-way. Listener only; reverting restores the old behavior.
Blast Radius: SDK modal callers
A merchant whose second
displayModalreplaces a pending one now gets a rejection on the first call where it used to hang. Code that awaits the first call and has no error handler will see an unhandled rejection instead of a silent hang.Not fixed here:
trackModalDisplay. When it does, the next request's takeover rejects a promise nobody awaits, which logs "Uncaught (in promise)".