Skip to content

Store local sessions separately#6931

Open
gonzaloriestra wants to merge 1 commit intomainfrom
store-sessions-per-env
Open

Store local sessions separately#6931
gonzaloriestra wants to merge 1 commit intomainfrom
store-sessions-per-env

Conversation

@gonzaloriestra
Copy link
Contributor

@gonzaloriestra gonzaloriestra commented Mar 3, 2026

WHY are these changes introduced?

In #5914 we added support for multiple sessions, but if you switch between environments (production/development), the sessions get overwritten, so you have to log in again.

WHAT is this pull request doing?

When running the CLI against the local environment, save the sessions in different store fields.

How to test your changes?

  • npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260303162727
  • shopify auth logout
  • shopify app versions list
  • SHOPIFY_SERVICE_ENV=local shopify app versions list
  • shopify app versions list
  • SHOPIFY_SERVICE_ENV=local shopify app versions list

It should only start the login flow once per environment.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.85% 14521/18416
🟡 Branches 73.16% 7224/9874
🟡 Functions 79.05% 3695/4674
🟡 Lines 79.19% 13720/17326

Test suite run success

3796 tests passing in 1449 suites.

Report generated by 🧪jest coverage report action from 99be1aa

@gonzaloriestra gonzaloriestra force-pushed the store-sessions-per-env branch from 3573760 to fc77660 Compare March 3, 2026 16:12
@gonzaloriestra
Copy link
Contributor Author

/snapit

@github-actions

This comment was marked as outdated.

@gonzaloriestra gonzaloriestra force-pushed the store-sessions-per-env branch 2 times, most recently from 721358e to 7e7ca2a Compare March 4, 2026 09:12
@gonzaloriestra gonzaloriestra force-pushed the store-sessions-per-env branch from 7e7ca2a to 99be1aa Compare March 4, 2026 09:24
@gonzaloriestra gonzaloriestra changed the title Store sessions per environment Store local sessions separately Mar 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Differences in type declarations

We 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:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/private/node/conf-store.d.ts
@@ -21,6 +21,8 @@ interface Cache {
 export interface ConfSchema {
     sessionStore: string;
     currentSessionId?: string;
+    devSessionStore?: string;
+    currentDevSessionId?: string;
     cache?: Cache;
 }
 /**

@gonzaloriestra
Copy link
Contributor Author

/snapit

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260304092735

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@gonzaloriestra gonzaloriestra marked this pull request as ready for review March 4, 2026 09:51
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner March 4, 2026 09:51
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.


function currentSessionIdKey(): 'currentDevSessionId' | 'currentSessionId' {
return isLocalEnvironment() ? 'currentDevSessionId' : 'currentSessionId'
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backward-compatibility break for existing “local” users (no migration / fallback)

The PR introduces new storage keys (devSessionStore, currentDevSessionId) for the local environment and switches reads/writes to those keys when isLocalEnvironment() is true. However, there’s no fallback to the old keys for users who already authenticated in local mode before this PR (where sessions would have been stored under sessionStore / currentSessionId even in local).

Evidence in code:

function sessionStoreKey(): 'devSessionStore' | 'sessionStore' {
  return isLocalEnvironment() ? 'devSessionStore' : 'sessionStore'
}

function currentSessionIdKey(): 'currentDevSessionId' | 'currentSessionId' {
  return isLocalEnvironment() ? 'currentDevSessionId' : 'currentSessionId'
}

In local env, getSessions() now reads only devSessionStore, and getCurrentSessionId() reads only currentDevSessionId. If a user already has valid sessions saved under the old keys from previous versions, the CLI will behave as if no session exists and will force a new login.

Impact:

  • Users who had already logged in with SHOPIFY_SERVICE_ENV=local will be unexpectedly prompted to log in again after upgrading.
  • Affects all existing “local” users upgrading to this version.
  • Can cause duplicated session records split across old/new keys.

@binks-code-reviewer
Copy link

🤖 Code Review · #projects-dev-ai for questions
React with 👍/👎 or reply — all feedback helps improve the agent.

Complete - 1 findings

📋 History

✅ 1 findings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant