fix(site): redirect to new organization after create - #26890
Merged
Conversation
The per-call onSuccess passed to mutateAsync only fires while the MutationObserver still has listeners. After the mutation succeeds the mutation-level onSuccess awaits invalidateQueries, which refetches the organizations list. The new list updates the organizationsPermissions query key, causing OrganizationSettingsLayout to render a Loader while the new query loads. That unmounts CreateOrganizationPage and tears down its mutation observer, so the per-call onSuccess is dropped and navigate never runs. When the permissions query resolves, the route remounts CreateOrganizationPage on /organizations/new with an empty form. Awaiting mutateAsync and calling navigate inline avoids the observer lifecycle entirely. Coder Agents generated.
DanielleMaywood
approved these changes
Jul 1, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
When submitting the create organization form on a deployment with more than a handful of organizations the form was being re-rendered as empty instead of taking the user to the freshly created organization, even though the API call succeeded.
The form posts through
mutateAsyncwith a per-callonSuccessthat callsnavigate. The mutation-levelonSuccessawaitsinvalidateQueries, which refetches the organizations list and changes theorganizationsPermissionsquery key. While that new query loads,OrganizationSettingsLayoutshows its loader and unmountsCreateOrganizationPage.@tanstack/react-queryonly fires per-call mutation callbacks when the observer still has listeners, so the navigate gets dropped. The form re-mounts on/organizations/newonce permissions resolve, which the user sees as an empty form.Awaiting
mutateAsyncand runningnavigateinline keeps the navigation out of the observer lifecycle.Coder Agents generated.