Conversation
| if (devSession && this.currentSessionState) { | ||
| const expectedWebsocketUrl = getWebSocketUrl(this.options.url) | ||
|
|
||
| if (devSession.websocketUrl !== expectedWebsocketUrl) { |
Contributor
There was a problem hiding this comment.
Should we better check if the URL OR the user changed? If you are working with localhost, another user may have updated your session, but the URL could be the same.
Contributor
There was a problem hiding this comment.
Good idea, updated!
|
|
||
| // Throw AbortError to terminate gracefully | ||
| throw new AbortError( | ||
| 'Dev session has been taken over by another user.', |
Contributor
There was a problem hiding this comment.
It could actually be yourself from a different tab or device. What about a generic copy like Your dev preview has been updated from another session? Or terminal?
Also, externally we refer to this as dev preview.
d7e0917 to
f2eb296
Compare
Contributor
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success3721 tests passing in 1438 suites. Report generated by 🧪jest coverage report action from ab545de |
29542fa to
4d3dbae
Compare
4d3dbae to
ab545de
Compare
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.

Summary
Implements client-side detection and handling for multi-user dev session conflicts, building on backend changes in https://github.com/shop/world/pull/383392 and https://github.com/shop/world/pull/386250.
When multiple developers run
shopify app devon the same app/shop combination, the CLI now provides clear feedback to both users about the session takeover and gracefully handles the conflict.Changes
GraphQL Query Updates
devSession,warnings, anduserErrorsfieldsdevSessionwith user and websocket informationSchema Updates
Updated local schema file (
app_dev_schema.graphql) to match backend changes:devSessionfield toDevSessionCreatePayloadwarningsarray toDevSessionCreatePayloaddevSessionfield toDevSessionUpdatePayloadDevSessionWarningandDevSessionWarningCodeenumImplementation (dev-session.ts)
Session State Tracking:
DevSessionStateinterface to track websocket URL and user informationcurrentSessionStateinstance variable to maintain session metadataCreate-Time Warning Display:
SESSION_TAKEOVER)Update-Time Takeover Detection:
websocketUrlagainst expected local websocket URL on every updateAbortErrorto gracefully terminate the dev session with actionable next stepsUser Experience
Scenario: User B Takes Over User A's Session
User A starts dev:
```bash
$ shopify app dev
✅ Ready, watching for changes in your app
```
User B starts dev (same app/shop):
⚠️ Another user is already running a dev preview for this app on example.myshopify.com.
```bash
$ shopify app dev
✅ Ready, watching for changes in your app
```
User A makes a code change:
```bash
[app-extension] Extension updated
❌ Error
⚠️ Another developer (user-b@shopify.com) has taken over this dev session.
└
Your preview is no longer active. Terminating dev session...
Dev session has been taken over by another user.
You can restart by running `shopify app dev` again.
```
Benefits
Dependencies
This PR depends on backend changes:
Testing Plan
Once backend PRs are merged:
Addresses https://github.com/shop/issues-develop/issues/21606
Measuring impact
Checklist