cli icon indicating copy to clipboard operation
cli copied to clipboard

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

Open jpallard6120 opened this issue 2 years ago • 19 comments

Please confirm that you have:

  • [X] 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.)
  • [X] 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

jpallard6120 avatar Jan 03 '24 16:01 jpallard6120

Trying to solve this issue, I made a clean installation of my dev environment with all the latest versions of everything. The issue still persists for this specific merchant.

Ubuntu 22.04 Node v21.5.0 Shopify CLI 3.53.0

There's nothing special within their templates/index.json that might explain this infinite loop.

jpallard6120 avatar Jan 03 '24 20:01 jpallard6120

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

ahmedbm27 avatar Jan 04 '24 09:01 ahmedbm27

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

iPhenan avatar Jan 04 '24 10:01 iPhenan

@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)

jpallard6120 avatar Jan 05 '24 15:01 jpallard6120

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 avatar Jan 10 '24 13:01 StanAngeloff

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!

ahmedbm27 avatar Jan 10 '24 18:01 ahmedbm27

@StanAngeloff Nice catch! Same issue here, I'd have never seen it otherwise. Thanks!

Shopify Team, still feel like this is a bug that should be fixed, as it's fairly common to copy/paste text from Figma. Maybe through an error message like the ones thrown when invalid schema is detected during a dev session?

jpallard6120 avatar Jan 10 '24 19:01 jpallard6120

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.

it worked 🎉🎉 Thanks aloooot

developersaintt avatar Jan 28 '24 07:01 developersaintt

@StanAngeloff I love you. Definitely would not have found that and this was driving me mad. And I agree with @jpallard6120 -- an error message would be great otherwise there's no way to know what's happening.

diegovogel avatar Feb 09 '24 15:02 diegovogel

Worked for me thank you for the fix @StanAngeloff

DannyTaki avatar Mar 07 '24 04:03 DannyTaki

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.

github-actions[bot] avatar Apr 19 '24 03:04 github-actions[bot]

@shopify-admins I feel this still warrants a bug fix!

jpallard6120 avatar Apr 22 '24 20:04 jpallard6120

Just ran into this issue too

JasonHassold avatar Apr 26 '24 22:04 JasonHassold

Also having this issue

jdunham2 avatar Apr 29 '24 13:04 jdunham2

Still having this issue too.

image

ceri-waterscreative avatar May 01 '24 07:05 ceri-waterscreative

Facing the exact same issue and don't have any unicode chars in my files.

rahulbhanushali avatar May 04 '24 02:05 rahulbhanushali

Having this as well, should definitely be fixed.

patrickdmccarthy avatar May 09 '24 17:05 patrickdmccarthy

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.

MaxDesignFR avatar May 17 '24 09:05 MaxDesignFR

Still having this issue too.

image

Add -x *.context.* in your command to exclude those locale templates from your hot reload.

So your cli dev command will look something like shopify theme dev --theme-editor-sync -x *.context.*

rightgeek avatar May 17 '24 19:05 rightgeek

Still facing issues with this also. Although MaxDesignFR's temporary fix seems to do the job. Any news on a permanent solution from the Shopify team?

RyanBriggsRCA avatar May 29 '24 08:05 RyanBriggsRCA

👋 Hey everyone,

If you're still facing this issue, could you please share your --verbose logs, ideally sharing the content of the JSON asset involved in the loop? With that, the assignee of this issue will be able to reproduce the exact scenario you're facing and fix it.

Thanks a lot for reporting!

karreiro avatar May 29 '24 15:05 karreiro

@karreiro Here's my verbose log (is this what you meant?) scratch_6.txt

The reload loop is caused by these unicode characters in settings_data.json. I'd be happy to share the entire file privately. Screen Shot 2024-05-31 at 2 41 08 PM

diegovogel avatar May 31 '24 18:05 diegovogel

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!

timdmackey avatar Jun 10 '24 20:06 timdmackey

Just to keep the post alive, I'm facing the same error in settings_schema.json. Can confirm also that the temporary solution works

CatalinGheorghiu avatar Jun 18 '24 17:06 CatalinGheorghiu

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.

surfwoodroad avatar Jun 18 '24 19:06 surfwoodroad

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.

visnaut avatar Jun 19 '24 17:06 visnaut

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.

stijns96 avatar Jun 19 '24 18:06 stijns96

@visnaut Hey, that seems to work for me, too! Funny, they just announced support for trailing commas, but didn't say they might be necessary, lol. In any case, thanks!

surfwoodroad avatar Jun 19 '24 20:06 surfwoodroad

Hi @karreiro,

Do you have an email address that I could send the verbose logs to? I'm not allowed to share this publicly.

From what I see is that it doesn't really show anything relevant except for the API that is actually using the unstable API under the hood.

Thanks!

stijns96 avatar Jun 20 '24 13:06 stijns96

:wave: Hey @stijns96,

Yeah, please, feel free to DM me in Partners Slack.

If you could send the --verbose log and one file that’s getting into the synchronization loop, that may help us on identifying the exact issue you’re facing.

Thanks a lot!

karreiro avatar Jun 20 '24 16:06 karreiro