fix(DesignerV2): Add re-entry guard to autoCreateConnectionIfPossible#9220
Merged
Conversation
… useEffect Fixes #9131. The useEffect in ConnectionPanel called autoCreateConnectionIfPossible without a re-entry guard, creating a loop. autoCreateConnectionIfPossible -> getUniqueConnectionName -> getConnectionsForConnector writes to the same React Query cache key as useConnectionsForConnector (which uses cacheTime/staleTime 0). The cache write produces a new connections array reference, re-triggering the effect, and the cycle repeats. The loop affects consumption-designer connectors with single auth (no connectionParameterSets), visible connection parameters, and an ARM resource ID — these reach getUniqueConnectionName before exiting. Add a useRef-based re-entry guard so the auto-create flow runs at most once per panel instance until it resolves (success / manual creation / error).
Contributor
🤖 AI PR Validation ReportPR Review ResultsThank you for your submission! Here's detailed feedback on your PR title and body compliance:✅ PR Title
✅ Commit Type
✅ Risk Level
✅ What & Why
✅ Impact of Change
✅ Test Plan
✅ Contributors
✅ Screenshots/Videos
Summary Table
This PR passes review for title and body compliance. The advised risk level is low and matches the submitter’s estimate.Last updated: Wed, 27 May 2026 15:57:37 GMT |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an infinite re-render/network-call loop in the Designer V2 ConnectionPanel by adding a re-entry guard around the useEffect that triggers autoCreateConnectionIfPossible, preventing repeated invocation caused by React Query cache writes producing new connections array references.
Changes:
- Added a
useRef-based re-entry guard to ensureautoCreateConnectionIfPossibleis not invoked concurrently/repeatedly due to cache updates. - Ensured the guard is released on success, manual creation path, and error (
catch) to avoid permanently blocking the flow.
Contributor
📊 Coverage Check🎉 All changed files have adequate test coverage! |
Covers the fix from #9220 / #9131 for the autoCreateConnectionIfPossible loop. Adds 15 tests across panel rendering and auto-create behavior, including the critical regression test that verifies autoCreateConnectionIfPossible is invoked exactly once even when the parent re-renders with a fresh empty connections array reference (the cache-write -> re-render cycle that caused the original loop).
ccastrotrejo
approved these changes
May 27, 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.
Commit Type
Risk Level
What & Why
Fixes #9131.
ConnectionPanelin designer-v2 invokesautoCreateConnectionIfPossiblefrom auseEffectwithout a re-entry guard, which causes an infinite loop for connectors with single auth.Root cause:
useConnectionsForConnectoris configured withcacheTime: 0andstaleTime: 0. When the effect callsautoCreateConnectionIfPossible, it transitively callsgetUniqueConnectionName→getConnectionsForConnector, which writes to the same React Query cache key as the hook. That cache write produces a newconnectionsarray reference, which changes the effect's dependency, re-runs the effect, and restarts the cycle. The result is a flood of redundantgetConnectionsand 404getConnectioncalls (and for connectors with no visible params, multiple concurrentcreateConnectionPUTs).Fix: Add a
useRef-based re-entry guard so the auto-create flow runs at most once per panel instance until it resolves (success / manual creation / error).Impact of Change
connectionParameterSets(multi-auth), since they exitautoCreateConnectionIfPossibleearly at theconnectorHasMultiAuthcheck.ConnectionPanel. The deeper architectural smell —useConnectionsForConnectorandgetConnectionsForConnectorsharing a query key while the hook hascacheTime: 0/staleTime: 0— is documented in aNOTEcomment but not refactored here.getConnections+ recursivegetConnection404s). Reduces latency before the create-connection panel renders. No new dependencies.Test Plan
main— pre-existing).Contributors
Screenshots/Videos
N/A — no visual change. Observable difference is in the browser network panel (no more loop of
getConnections/getConnection 404calls when opening the connection panel for an affected connector).