Repository navigation
Fix saved account loss across concurrent CLI sessions - #8973
Draft
isaacroldan wants to merge 1 commit into
Draft
isaacroldan wants to merge 1 commit into
isaacroldan wants to merge 1 commit into
Conversation
Contributor
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/private/node/conf-store.d.ts@@ -26,6 +26,8 @@ export interface ConfSchema {
cache?: Cache;
autoUpgradeEnabled?: boolean;
}
+/** Serializes session mutations across CLI processes without holding a lock during authentication. */
+export declare function withSessionStoreLock<T>(action: () => Promise<T>, config?: LocalStorage<ConfSchema>): Promise<T>;
/**
* Get session.
*
packages/cli-kit/dist/public/node/local-storage.d.ts@@ -8,6 +8,12 @@ export declare class LocalStorage<T extends Record<string, any>> {
projectName?: string;
cwd?: string;
});
+ /**
+ * Returns the path of the local storage file.
+ *
+ * @returns The absolute path of the local storage file.
+ */
+ get path(): string;
/**
* Get a value from the local storage.
*
packages/cli-kit/dist/private/node/session/store.d.ts@@ -1,19 +1,22 @@
+import type { ConfSchema } from '../conf-store.js';
+import type { LocalStorage } from '../../../public/node/local-storage.js';
import type { Sessions } from './schema.js';
/**
- * Serializes the session as a JSON and stores it in the system.
- * @param session - the session to store.
+ * Merges changed sessions into the latest stored accounts.
+ * @param sessions - Only the sessions changed by the caller.
+ * @param config - Optional local storage instance.
*/
-export declare function store(sessions: Sessions): Promise<void>;
+export declare function store(sessions: Sessions, config?: LocalStorage<ConfSchema>): Promise<void>;
/**
* Fetches the sessions from the local storage and returns it.
- * If the format of the object is invalid, the method will discard it.
+ * Unreadable data is preserved instead of removing every saved account.
* @returns Returns a promise that resolves with the sessions object if it exists and is valid.
*/
-export declare function fetch(): Promise<Sessions | undefined>;
+export declare function fetch(config?: LocalStorage<ConfSchema>): Promise<Sessions | undefined>;
/**
* Removes a session from the system.
*/
-export declare function remove(): Promise<void>;
+export declare function remove(config?: LocalStorage<ConfSchema>): Promise<void>;
/**
* Gets the session alias for a given user ID.
*
@@ -27,7 +30,7 @@ export declare function getSessionAlias(userId: string): Promise<string | undefi
* @param userId - The user ID of the session to update.
* @param alias - The new alias to set.
*/
-export declare function setSessionAlias(userId: string, alias: string): Promise<void>;
+export declare function setSessionAlias(userId: string, alias: string, config?: LocalStorage<ConfSchema>): Promise<void>;
/**
* Finds a session by its alias.
*
|
isaacroldan
marked this pull request as draft
October 21, 2026 10:05
This branch has not been 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.
WHY are these changes introduced?
Overlapping CLI processes can replace the saved account list with an older copy after a login or token refresh. A refresh can also change the selected account, and some authentication failures remove every saved account.
WHAT is this pull request doing?
Merge only changed accounts into the latest store under a short process lock. Use the same lock for alias updates and logout, and keep the selected account unchanged during a refresh.
Preserve saved accounts when a refresh returns
invalid_request, authentication cannot prompt for a new sign-in, or the stored session format cannot be read. Unreadable data produces a recovery message instead of being deleted.Existing CLI versions that do not contain this fix can still overwrite the shared store; both processes must use the fix for coordinated writes.
How to manually test your changes?
pnpm shopify auth loginand use “Log in with a different account” to sign in with separate accounts at the same time.pnpm shopify auth loginagain. Confirm that both accounts remain available and select one.pnpm shopify app dev --path /path/to/your/apprunning in one terminal, select the other saved account in the second terminal. After the dev process refreshes its credentials, confirm that both accounts remain available and the selected account has not changed.Validation
git diff --checkpass on Node 24.15.0.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add