Repository navigation
Conversation
createClient deleted the existing client then inserted a new one, so two requests for the same username could both pass the delete and the second insert hit the primary key. Upsert instead, so the last request wins as it already does when they arrive one after the other. Closes #9019
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9020 +/- ##
=======================================
Coverage 79.46% 79.46%
=======================================
Files 475 475
Lines 26028 26028
Branches 6938 6938
=======================================
Hits 20684 20684
Misses 5344 5344
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch was successfully deployed
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.
Closes #9019
POST /teams/:id/comms-credentialsgoes throughcreateClient, which looks up the existing broker client for the username, destroys it, then creates a new one. The username for a team frontend client is built from the tab'ssessionId, and that lives in sessionStorage, which the browser copies into duplicated and restored tabs. So after a browser restore several tabs ask for the same username at the same moment, both get past the destroy, and the second insert hits theusernameprimary key and 500s. The tab's team connection treats a credential failure as terminal, so that tab stays without live updates until it's reloaded. That's FLOWFUSE-BACKEND-9X in Sentry (176 events, 44 users).The insert is now an
upserton the username, so concurrent requests can't collide and the last one written wins, which is already what happens when they arrive one after the other. The destroy stays as it is, since some callers look the existing client up by owner rather than by username.Reproduced locally by firing 4 concurrent requests with one
sessionId: two of them 500 every round. With the fix, 20 out of 20 came back 200. Added a route test for the concurrent case that fails before the fix and also checks the stored password still authenticates throughupsert. The controller spec stubs moved fromcreatetoupsert, and the broker controller and comms auth tests all pass.