fix: set reusedStoredClient before createFlow in joined-flow path

When joining a PENDING flow, reusedStoredClient was only set on the
success return but not before the await. If createFlow throws (e.g.
invalid_client during token exchange), the outer catch returns the
local variable which was still false, skipping stale-client cleanup.
This commit is contained in:
Danny Avila 2026-04-03 20:18:10 -04:00
parent a78b8db3e8
commit 6fcb0f57eb

View file

@ -596,6 +596,7 @@ export class MCPConnectionFactory {
await this.oauthStart(storedAuthUrl);
}
reusedStoredClient = flowMeta?.reusedStoredClient === true;
const tokens = await this.flowManager.createFlow(flowId, 'mcp_oauth', {}, this.signal);
if (typeof this.oauthEnd === 'function') {
await this.oauthEnd();