fix: gracefully handle dismissed interface errors in background jobs#589
fix: gracefully handle dismissed interface errors in background jobs#589ulissesferreira wants to merge 2 commits into
Conversation
65c22ad to
5b54030
Compare
5b54030 to
530485d
Compare
530485d to
5209704
Compare
|
5209704 to
debd97e
Compare
Add `*IfExists` variants of interface methods that return null instead of throwing when an interface has been dismissed by the user: - Add `isInterfaceNotFoundError` helper to detect interface not found errors - Rename `getInterfaceContext` to `getInterfaceContextIfExists` with error handling - Add `updateInterfaceIfExists` for defensive updates in async operations - Remove unused `getInterfaceContextOrThrow` function - Update background jobs to use new methods and clean up state on dismissal - Add unit tests for the new error handling behavior This prevents noisy error logs when users dismiss confirmation dialogs while background operations (price refreshes, security scans) are still running.
debd97e to
74cd0c1
Compare
74cd0c1 to
2bcf508
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| if (currentMap[SEND_FORM_INTERFACE_NAME] === interfaceId) { | ||
| await state.deleteKey(`mapInterfaceNameToId.${SEND_FORM_INTERFACE_NAME}`); | ||
| } | ||
| } |
There was a problem hiding this comment.
Duplicated deleteInterfaceIdIfCurrent helper across two files
Low Severity
deleteInterfaceIdIfCurrent is defined as a near-identical local function in both refreshSend.tsx and refreshConfirmationEstimation.tsx. The only difference is the interface name constant used. This could be a single shared utility in interface.ts that accepts the interface name as a parameter, reducing duplication and ensuring consistent cleanup behavior across background jobs.





Summary
When users dismiss confirmation dialogs (click outside, press escape, or close them), background operations like price refreshes and security scans may still be running. These operations would try to update or read from the dismissed interface, causing noisy "Interface not found" errors in the logs.
This PR implements graceful error handling by adding
*IfExistsvariants of interface methods that returnnullinstead of throwing when an interface has been dismissed.Changes
New Methods in
interface.tsisInterfaceNotFoundError(error)getInterfaceContextIfExists(id)nullif dismissedgetInterfaceContextupdateInterfaceIfExists(id, ui, ctx)nullif dismissedNaming Convention
*IfExistssuffix explicitly indicate they swallow "interface not found" errorsupdateInterfaceis kept for event handlers where the interface must existgetInterfaceContextOrThrowfunctionBackground Jobs Updated
refreshSend.tsx- Token price refresh (every 30s)refreshConfirmationEstimation.tsx- Security scan refresh (every 20s)buildTransactionMessageAndUpdateInterface.tsx- Transaction buildingThese now:
*IfExistsmethods for defensive error handlingmapInterfaceNameToId) when interface is dismissedTest Plan
yarn test:core)yarn test:features)isInterfaceNotFoundError,getInterfaceContextIfExists, andupdateInterfaceIfExistsNote
Medium Risk
Touches shared interface utilities and multiple async UI/background update paths; mistakes could cause silent UI non-updates or stale
mapInterfaceNameToIdentries, but changes are localized to handling dismissed interfaces.Overview
Prevents noisy "Interface not found" errors when users dismiss dialogs while async work is still running by adding
isInterfaceNotFoundError,getInterfaceContextIfExists, andupdateInterfaceIfExiststo swallow dismissed-interface failures.Updates the send and confirmation refresh cronjobs and related UI render/update flows to use the new
*IfExistshelpers, early-exit when the UI is gone, and proactively cleanmapInterfaceNameToIdstate entries; includes new unit coverage for the interface helpers and a manifestshasum/changelog bump.Written by Cursor Bugbot for commit 2bcf508. This will update automatically on new commits. Configure here.