I've noticed that if the user signup step is not at the first place in a signup flow, redirecting from the login screen (after clicking "Already have a WP account?") back to the signup flow resets the progress and user ends up in a loop so that you can't create a new site by logging in to an existing account.
For example, go to wordpress.com/start/developer. Fill in the site and go to the user step. There, click on "Already have a WP account?". Log in. You'll be redirected back to wp.com/start/developer. However, you'll land on the new site step again and have to repeat your desired site address. Only then you successfully finish the flow.

I noticed this as we are working on the P2 signup flow and have the user step as the last one instead of the first one which triggers this behavior.
cc @Automattic/ganon for help here too š
Recent findings:
state/signup/progress).user step as the first one as there's no progress made ā you first log in, then are redirected back to the signup flow. The user step is removed from the flow and you can continue the flow as normal.user step is not in the first place of a signup flow, the signup progress gets cleared/reset on redirecting from the wpcom login screen.state/signup subtree is persisted (with it state/signup/progress) it's somehow cleared after redirecting from the login screen back to the signup flow.We should find out why and how the state/signup subtree is cleared and if possible, prevent it so we can continue with the signup flow from the last finished step.
We should find out why and how the state/signup subtree is cleared and if possible, prevent it so we can continue with the signup flow from the last finished step.
Maybe this will help explain why we cleared the store after login: https://github.com/Automattic/wp-calypso/pull/38330
Back in the day, we had to clear the signup store so that we could ensure users could return to the onboarding flow in a clean state.
https://github.com/Automattic/wp-calypso/blob/4d27b9a/client/signup/main.jsx#L362
Maybe you could toy around with clearing based on the flow?
Also, @andrewserong implemented an A/B experiment that pushed the user step to the last step in the flow, while preserving user data: https://github.com/Automattic/wp-calypso/pull/34770
That might yield some clues as well as how to approach it for the p2 flow.
This is great info @ramonjd, thanks for the pointers! Gonna check it now.
So, this recent PR https://github.com/Automattic/wp-calypso/pull/44106 helped to transfer the signup redux state from the logged out session to the logged in session.
However, I found out itās āfarā from being done and fixed. āfarā in quotes because it might not be too much code but in order to completely fix it, I have to fully understand the core signup logic which is kinda huge.
In https://github.com/Automattic/wp-calypso/pull/34770, what they did was to dispatch a āresumeā action after logging in which would mark the last step as āin-progressā so user would be redirected to it. The downside is that the user has to repeat the last step. The upside that it helps the signup flow process stuff in normal way.
It wouldnāt help us much because our flow basically has only one step (the p2-site one). So what Iām trying to do is to automagically submit and process the p2-site step after logging in.
I think I might have some solution which Iāll try but itās not super nice.
tl;dr signup flow was not made for these kinds of things and it needs a bit of rework or perhaps hacks around (which Iām trying) which might be ugly and not pass review.