A background token refresh failure in a non-interactive process wipes every saved CLI session (all accounts)
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- authentication, cli
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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 devprocesses 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 devprocesses were running,config.jsonended up with only thecachekey;sessionStoreandcurrentSessionIdwere gone. - The
theme devterminals showed no error. The next command in another terminal required a full device login.
Relevant code (main @ 060e88b)
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 bothneeds_full_authandInvalidGrantErrorduring refresh:
https://github.com/Shopify/cli/blob/060e88b3b9d8c6ca01dfa50bbb442ce6470060e2/packages/cli-kit/src/private/node/session.ts#L252-L271- The theme dev auto-refresher runs every 30 minutes with
noPrompt: trueand swallows failures:
https://github.com/Shopify/cli/blob/060e88b3b9d8c6ca01dfa50bbb442ce6470060e2/packages/theme/src/cli/utilities/theme-environment/dev-server-session.ts#L56-L63 - 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)
shopify auth login- Start
shopify theme devagainst 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). - Check
config.json:sessionStoredisappears 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 devloses 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.
- Ngôn ngữ chính
- TypeScript
- Star
- 763
- Fork
- 295
- Merge trung bình
- 4 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 175
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Shopify/cli
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
Shopify/cli#8906 · 1 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug]: app deploy fails intermittently with ENOENT on <handle>.js.map when two UI extensions share a folderCó thể đã có người làm @efegokdemir đã nhận 15 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 67/100
Shopify/cli#8823 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Shopify/cli#8753 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug]: `theme dev` proxy 502s on cookie-heavy storefront responses (undici default 16 KiB `maxHeaderSize`)Có thể đã có người làm @efegokdemir đã nhận 21 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Shopify/cli#8717 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug]: `shopify hydrogen dev` exits before listening when the npm registry is unreachable (p-cancelable onCancel-after-settle in latest-version chunk)Có thể đã có người làm @efegokdemir đã nhận 20 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
area: image-engine bug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
snapotter-hq/SnapOtter#3885 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Mend: dependency security vulnerability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 3 ngày
-
pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug P3 UI/UX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
openclaw/openclaw#182077 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày