Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

A background token refresh failure in a non-interactive process wipes every saved CLI session (all accounts)

オープン
#8,945 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@efegokdemir がすでに取り組んでいます。

2026年10月19日 から。

  • #8946 @efegokdemir による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript

調査の方向性

Start with packages/cli-kit/src/private/node/session.ts, especially throwOnNoPrompt() and the refresh paths, then read packages/theme/src/cli/utilities/theme-environment/dev-server-session.ts to see how refresh failures are handled. Reproduce the reported behavior with concurrent shopify theme dev processes and inspect the shared config.json. Done means a refresh failure no longer removes unrelated saved sessions, concurrent refreshes do not overwrite valid session data, and users can see when theme dev loses its session.

索引モデルが issue の本文から書いたものです。

説明

Summary

When a long-running CLI process (e.g. shopify theme dev) hits a refresh failure while running with noPrompt: true, throwOnNoPrompt() calls logout(), which removes the entire session store (sessionStore + currentSessionId) from config.json, for every account and alias. Because the theme dev auto-refresher swallows the error (outputDebug('Session could not be refreshed.')), nothing is shown to the user. The next CLI command in any terminal then asks for a full login.

On a machine that runs several CLI processes at the same time, this makes the CLI feel like it "expires" every few hours.

Environment
  • Shopify CLI 4.9.4 (Homebrew), macOS, Apple Silicon
  • Several shopify theme dev processes for different stores running at the same time, plus one-off CLI commands from scripts/other terminals, all sharing the same ~/Library/Preferences/shopify-cli-kit-nodejs/config.json
Observed
  • While two shopify theme dev processes were running, config.json ended up with only the cache key; sessionStore and currentSessionId were gone.
  • The theme dev terminals showed no error. The next command in another terminal required a full device login.
Relevant code (main @ 060e88b)
  1. throwOnNoPrompt() logs out before it throws, so one non-interactive process failing removes the sessions every other process relies on:
    https://github.com/Shopify/cli/blob/060e88b3b9d8c6ca01dfa50bbb442ce6470060e2/packages/cli-kit/src/private/node/session.ts#L298-L307
    It is reached from both needs_full_auth and InvalidGrantError during refresh:
    https://github.com/Shopify/cli/blob/060e88b3b9d8c6ca01dfa50bbb442ce6470060e2/packages/cli-kit/src/private/node/session.ts#L252-L271
  2. The theme dev auto-refresher runs every 30 minutes with noPrompt: true and swallows failures:
    https://github.com/Shopify/cli/blob/060e88b3b9d8c6ca01dfa50bbb442ce6470060e2/packages/theme/src/cli/utilities/theme-environment/dev-server-session.ts#L56-L63
  3. The session store is read, modified and written back as a whole. I couldn't find any cross-process lock around it:
    https://github.com/Shopify/cli/blob/060e88b3b9d8c6ca01dfa50bbb442ce6470060e2/packages/cli-kit/src/private/node/session.ts#L273-L284
Suspected trigger (not confirmed)

Two processes refresh at around the same time using the same refresh token, or one overwrites the store with stale tokens after the other has refreshed. If refresh tokens are rotated, the later refresh gets invalid_grant, which goes through throwOnNoPrompt(), which wipes all sessions. I couldn't confirm whether Identity rotates refresh tokens, but the "one failure clears everything" behaviour comes straight from the code above, whatever causes the refresh to fail.

Steps to reproduce (likely)
  1. shopify auth login
  2. Start shopify theme dev against two different stores in two terminals and leave them running for a few hours (past the access-token expiry, so the 30-minute auto-refresher has to refresh).
  3. Check config.json: sessionStore disappears at some point, and the next CLI command asks for a full login.
Expected
  • A refresh failure in one non-interactive process should not delete sessions for other processes or accounts. At most it should fail that process, or invalidate only the session it was using.
  • Concurrent refreshes should be serialized (file lock), or the store should be re-read before writing, so that processes don't invalidate each other's tokens.
  • When theme dev loses its session, the user should see it in the terminal instead of a debug-only log line.
Related

#5826 and #3173 report similar "randomly signed out / unable to prompt for reauthentication" symptoms. Both were closed after fixes to single-process error handling. The multi-process case doesn't seem to be covered.

主要言語
TypeScript
スター
757
フォーク
294
平均マージ
4日 12時間
マージ済み PR(30日)
175

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Shopify/cli のほかの issue

Shopify/cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。