cli: [Bug]: Shopify CLI keeps refreshing when theme-editor-sync = true

Please confirm that you have:

  • Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

Theme

Expected behavior

Running shopify theme dev --theme-editor-sync should start the live-preview server, and update code within the dev customizer in both directions.

Actual behavior

Despite having the same templates/index.json file locally and on the development theme, a choice appears:

The local file templates/index.json is different from the remote version in the development theme.
? What would you like to do? (Choose with ↑ ↓ ⏎, filter with 'f')
> 1. Keep the remote version
  2. Keep the local version
  3. Merge files (it may break the local file)
  4. Exit

Verbose output

Whatever choice is used, the live-preview gets stuck in an infinite get/update loop:

  • 11:13:25 Synced » get templates/index.json                                                                                                                                                               
  • 11:13:26 Synced » update templates/index.json                                                                                                                                                            
  • 11:13:29 Synced » get templates/index.json                                                                                                                                                               
  • 11:13:29 Synced » update templates/index.json
  • 11:13:32 Synced » get templates/index.json
  • 11:13:33 Synced » update templates/index.json
  • 11:13:36 Synced » get templates/index.json
  • 11:13:36 Synced » update templates/index.json

and so on

Reproduction steps

This happens on a specific store, but not on others. Will be hard to reproduce on a different store, as I don’t know the cause of the issue.

Operating System

Ubuntu 20.04

Shopify CLI version (check your project’s package.json if you’re not sure)

@shopify/cli/3.53.0

Shell

bash

Node version (run node -v if you’re not sure)

node-v18.19.0

What language and version are you using in your application?

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 13
  • Comments: 57 (7 by maintainers)

Most upvoted comments

I recently had this within the team. For us it was Unicode hiding in plain sight. A U+2028 LINE SEPARATOR character got inserted when copying multiline text from, e.g., Figma, into a single-line text box in the theme editor. Getting rid of the extra ‘invisible’ Unicode characters causes the loop to stop for us.

image

The loop also happens if U+2028 is inserted unescaped. It won’t show up in VS Code, however on opening the file for the first time you should get prompted to ignore or remove the LS/PS characters.

I’ve been experiencing this on several merchants in the recent past (~4mo).

I’ve been able to come up with a replicable scenario in CLI 3.62.0 that doesn’t seem to be related to the use cases above, but nonetheless causes the same endless loop issue:

  1. Create a settings_schema.json file with the following content:
[
  {
    "name": "theme_info",
    "theme_name": "Blank",
    "theme_version": "1.0.0",
    "theme_author": "RunDTC",
    "theme_documentation_url": "https://help.shopify.com/manual/online-store/themes",
    "theme_support_url": "https://support.shopify.com/"
  }
]
  1. Observe/confirm that there are no hidden unicode characters in that file.
  2. Upload the above by running shopify theme dev. Confirm that no errors are reported, and stop the command (^C).
  3. Run shopify theme dev --theme-editor-sync. Confirm that output displays in an endless loop of get and update on config/settings_schema.json; any changes made and saved to that file locally get immediately overwritten.
  4. Stop running command. Add a comma after the closing curly bracket:
[
  {
    "name": "theme_info",
    "theme_name": "Blank",
    "theme_version": "1.0.0",
    "theme_author": "RunDTC",
    "theme_documentation_url": "https://help.shopify.com/manual/online-store/themes",
    "theme_support_url": "https://support.shopify.com/"
  },
]
  1. Upload the above by running shopify theme dev. Confirm that no errors are reported.
  2. Run shopify theme dev --theme-editor-sync. Confirm that there is no endless loop of getting/updating config/settings_schema.json

This one’s a bit weird, because strict adherence to the JSON spec in settings/locales/templates is required to avoid upload errors on Shopify; but in this case an extra comma prevents this endless loop.

This is also an edge case, because a mostly empty config/settings_schema.json is not likely on any merchant. But I’m hoping that a replicable version of this might help identify the underlying issue.

Can confirm I get this also - constantly get/update of settings_schema.json. The temp. fix of cutting the contents, saving, pasting and then resaving works but only for that CLI session.

Really a shame that CLI has seen a decrease in quality over these past updates.

A temporary solution I found when this happens is to empty the file that is stuck in an infinite loop (copy to clipboard) => save file => paste the file content => save.

As a note, something really does need to be done about this, because most code editors these days do auto formatting of files, which does not support the trailing comma as its not part of the spec of JSON. This is causing a massive headache of having to manually copy files when making changes, rather than letting the CLI handle those changes.

Just “add a trailing comma” is not really a solution when so many tools these days do things to help ensure standards are being followed.

@ahmedbm27 @iPhenan I found a temporary bandaid, if the issue is related to a single file like me. You can add flag ignore = [“templates/index.json”] (or whatever file is problematic) and you’ll be able to use customizer sync again (except the ignored file)

👋 Hey everyone,

Thank you for your input and all the details about this issue. We’ve released a new version of the Shopify CLI some minutes ago with the fix (3.63.2). Please, if this problem persists, don’t hesitate to reach out and share your --verbose output here.

Thanks again for reporting!

get this issue still too, only since the latest CLI update though

👋 Hey @Topenze,

Could you please run the command with the --verbose flag and share those logs? With that, we may get extra pointers about the exact scenario you’re facing and track the requests involved with that.

Thanks a lot!

The issue seems to have stopped. However, every time I run theme dev, I get this Reconciliation strategy prompt, I’ve deleted the development theme and also ran the logout command but I still always get this prompt, how do I prevent this please? Image Image

I haven’t found any bad characters, but it is running “get” and “update” for config/settings_schema.json. I’ve checked with the Gremlins extension in VS Code - there seems to be no problem with the file. I’ve tried the copy/paste thing, but that has no effect. It is getting and updating every 1-3 seconds. I also just updated to the latest CLI version, so this has happened in 3.57 and 3.62.

I have exactly the same issue at the moment. Not with all project, but just some.

What I also found out is that if I go to my folder where the shopify files are living (./theme) in this case and then run the command, it works fine. But as soon as that I run the command from the root with --path ./theme, it will give me this error.

A temporary solution I found when this happens is to empty the file that is stuck in an infinite loop (copy to clipboard) => save file => paste the file content => save.

Thanks for this! I just wanted to note that this is indeed a temporary solution. Once you end restart the syncing process, the error recurs with the same files as before (at least it does for me). But at least I can fix the issue for a single working session!

I recently had this within the team. For us it was Unicode hiding in plain sight. A U+2028 LINE SEPARATOR character got inserted when copying multiline text from, e.g., Figma, into a single-line text box in the theme editor. Getting rid of the extra ‘invisible’ Unicode characters causes the loop to stop for us.

image

The loop also happens if U+2028 is inserted unescaped. It won’t show up in VS Code, however on opening the file for the first time you should get prompted to ignore or remove the LS/PS characters.

@StanAngeloff
You’re right! I deleted the Unicode U+2028 from the template JSON file, which helped us stop the infinite loop.Thank you!

Same issue on Apple M1, MacOS 14.2.1 since Shopify CLI version 3.52.0

I’m facing the identical issue with the following:

  • Operating System: Ubuntu 23.04
  • Node.js version: v21.5.0
  • Shopify CLI version: Tested with both 3.52.0 and 3.53.0