Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Execute Shopify theme dev with error message: request to xxx.theme.json?xxx processing failed, reason: read ETIMEDOUT #3225

Closed
2 tasks done
MyBaymax opened this issue Jan 5, 2024 · 83 comments
Labels
Area: @shopify/theme @shopify/theme package issues Type: Bug Something isn't working

Comments

@MyBaymax
Copy link

MyBaymax commented Jan 5, 2024

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

Start development services

Actual behavior

request to https://amirobeauty-com.myshopify.com/admin/api/unstable/themes
│ .json?fields=id%2Cname%2Crole%2Cprocessing failed, reason: read ETIMEDOUT

Verbose output

2024-01-05T05:38:22.631Z: Running command theme dev
  shopify:theme:dev init version: @oclif/[email protected] argv: [ '-t=162423603516', '-s=amirobeauty-com', '--verbose' ] +0ms
2024-01-05T05:38:22.653Z: Ensuring that the user is authenticated with the Theme API with the following scopes:
[]

2024-01-05T05:38:22.654Z: Ensuring that the user is authenticated with the Admin API with the following scopes for the store amirobeauty-com.myshopify.com:
[]

2024-01-05T05:38:22.654Z: Getting session store...
2024-01-05T05:38:22.658Z: Validating existing session against the scopes:
[
  "openid",
  "https://api.shopify.com/auth/shop.admin.graphql",
  "https://api.shopify.com/auth/shop.admin.themes",
  "https://api.shopify.com/auth/partners.collaborator-relationships.readonly",
  "https://api.shopify.com/auth/shop.storefront-renderer.devtools",
  "https://api.shopify.com/auth/partners.app.cli.access",
  "https://api.shopify.com/auth/destinations.readonly"
]
For applications:
{
  "adminApi": {
    "scopes": [],
    "storeFqdn": "amirobeauty-com.myshopify.com"
  }
}

2024-01-05T05:38:22.659Z: Sending Identity Introspection request to URL: https://accounts.shopify.com/oauth/introspection
2024-01-05T05:38:22.659Z: Sending POST request to URL https://accounts.shopify.com/oauth/introspection
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:23.347Z: Request to https://accounts.shopify.com/oauth/introspection completed in 674 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"1858cd7de013df56d8f94ed0f5bfefcc"
 - x-request-id: b87ed319-ea71-4e0c-92cc-0014e2c92be1
    
2024-01-05T05:38:23.359Z: The identity token is valid: true
2024-01-05T05:38:23.359Z: 
The validation of the token for application/identity completed with the following results:
- It's expired: false
- It's invalid in identity: false
  
2024-01-05T05:38:23.360Z: The current session is valid but needs refresh. Refreshing...
2024-01-05T05:38:23.364Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=refresh_token&access_token=atkn_CjQIoqverAYQwuPerAZSJggBEhCYyQfZG_FItoPH5HuDCJ8uGhDiMj-HiV1EsqpxTEMrCa8QEkDhw3xvxAMSewT92n5Cs1tTJfeGSkbr7EKZWb9_rk_Dbm25Afg5T8Sn3Cyhq8mPHq4XlH4AELwGJiX_LJ-FybwB&refresh_token=atkn_CiEIoqverAYQosX8rQaiARIKEOIyP4eJXUSyqnFMQysJrxASQGpA8QjIt_Eb1oH-IrlAeS_2dK7_oHw56fEQwjdaiZT-XH2dY53UukzAQTaAmdVcH7sqpAwu0DFmkswjENVEAgI&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.051Z: Request to https://accounts.shopify.com/oauth/token?grant_type=refresh_token&access_token=atkn_CjQIoqverAYQwuPerAZSJggBEhCYyQfZG_FItoPH5HuDCJ8uGhDiMj-HiV1EsqpxTEMrCa8QEkDhw3xvxAMSewT92n5Cs1tTJfeGSkbr7EKZWb9_rk_Dbm25Afg5T8Sn3Cyhq8mPHq4XlH4AELwGJiX_LJ-FybwB&refresh_token=atkn_CiEIoqverAYQosX8rQaiARIKEOIyP4eJXUSyqnFMQysJrxASQGpA8QjIt_Eb1oH-IrlAeS_2dK7_oHw56fEQwjdaiZT-XH2dY53UukzAQTaAmdVcH7sqpAwu0DFmkswjENVEAgI&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3 completed in 682 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"7aea3781ee472647f2dd168c9546b2d5"
 - x-request-id: ff1e2970-b8df-4b8f-8f6b-e1fcb5c361c4
    
2024-01-05T05:38:24.059Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=****
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.059Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=ee139b3d-5861-4d45-b387-1bc3ada7811c&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.storefront-renderer.devtools&subject_token=****
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.059Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=32ff8ee5-82b8-4d93-9f8a-c6997cefb7dc&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly&subject_token=****
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.059Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.graphql+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.themes+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly&subject_token=****&destination=https%3A%2F%2Famirobeauty-com.myshopify.com%2Fadmin
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:24.715Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=ee139b3d-5861-4d45-b387-1bc3ada7811c&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.storefront-renderer.devtools&subject_token=**** completed in 646 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"0aafaab49c7da130c0eb9b2c2b4531bb"
 - x-request-id: 0c4d9712-b5cc-48b1-a756-4cdfb2ec977a
    
2024-01-05T05:38:24.727Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=**** completed in 661 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"ef12c0211829f8adabc1f8140f9696f6"
 - x-request-id: f0ef61a5-c596-460b-9fef-4e0487168404
    
2024-01-05T05:38:24.733Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.graphql+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.themes+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly&subject_token=****&destination=https%3A%2F%2Famirobeauty-com.myshopify.com%2Fadmin completed in 657 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"43ebc473530be7e146a89f7ed544ec75"
 - x-request-id: d9e5070d-9c69-428f-bfd6-5cb3631afff7
    
2024-01-05T05:38:24.743Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=32ff8ee5-82b8-4d93-9f8a-c6997cefb7dc&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly&subject_token=**** completed in 672 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"ad972dff4f4847856b336befe6d77749"
 - x-request-id: 78d4eea6-e423-4f26-87fa-3b3a77dfcbd4
    
2024-01-05T05:38:24.746Z: Setting session store...
2024-01-05T05:38:24.754Z: Ensuring that the user is authenticated with the Storefront API with the following scopes:
[]

2024-01-05T05:38:24.755Z: Getting session store...
2024-01-05T05:38:24.758Z: Validating existing session against the scopes:
[
  "openid",
  "https://api.shopify.com/auth/shop.admin.graphql",
  "https://api.shopify.com/auth/shop.admin.themes",
  "https://api.shopify.com/auth/partners.collaborator-relationships.readonly",
  "https://api.shopify.com/auth/shop.storefront-renderer.devtools",
  "https://api.shopify.com/auth/partners.app.cli.access",
  "https://api.shopify.com/auth/destinations.readonly"
]
For applications:
{
  "storefrontRendererApi": {
    "scopes": []
  }
}

2024-01-05T05:38:24.758Z: Sending Identity Introspection request to URL: https://accounts.shopify.com/oauth/introspection
2024-01-05T05:38:24.758Z: Sending POST request to URL https://accounts.shopify.com/oauth/introspection
With request headers:
 - User-Agent: Shopify CLI; v=3.51.2
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-01-05T05:38:25.385Z: Request to https://accounts.shopify.com/oauth/introspection completed in 624 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"4c322ab9b3ca704742af61217c25bba1"
 - x-request-id: 5e2fe173-6ac8-46f9-9f02-1fdf0df387c4
    
2024-01-05T05:38:25.389Z: The identity token is valid: true
2024-01-05T05:38:25.389Z: 
The validation of the token for application/identity completed with the following results:
- It's expired: false
- It's invalid in identity: false
  
2024-01-05T05:38:25.406Z: 
Running system process:
  · Command: /usr/local/opt/ruby/bin/ruby -v
  · Working directory: /Users/baymax/Desktop/vscode/amiro

2024-01-05T05:38:25.457Z: 
Running system process:
  · Command: /usr/local/opt/ruby/bin/bundle -v
  · Working directory: /Users/baymax/Desktop/vscode/amiro

2024-01-05T05:38:25.601Z: Reading the content of file at /usr/local/Cellar/shopify-cli/3.51.2/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/assets/cli-ruby/Gemfile...
2024-01-05T05:38:25.603Z: 
Running system process:
  · Command: /usr/local/opt/ruby/bin/bundle install
  · Working directory: /usr/local/Cellar/shopify-cli/3.51.2/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/assets/cli-ruby

2024-01-05T05:38:25.871Z: 
Running system process:
  · Command: /usr/local/opt/ruby/bin/bundle exec /usr/local/opt/ruby/bin/ruby /usr/local/Cellar/shopify-cli/3.51.2/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/assets/cli-ruby/bin/shopify theme token --admin atkn_Cp8DCNCr3qwGEPDj3qwGYpADCAESEDKFuqv6eUvGgCTwcNV671oaqAFodHRwczovL2FwaS5zaG9waWZ5LmNvbS9hdXRoL3BhcnRuZXJzLmNvbGxhYm9yYXRvci1yZWxhdGlvbnNoaXBzLnJlYWRvbmx5IGh0dHBzOi8vYXBpLnNob3BpZnkuY29tL2F1dGgvc2hvcC5hZG1pbi5ncmFwaHFsIGh0dHBzOi8vYXBpLnNob3BpZnkuY29tL2F1dGgvc2hvcC5hZG1pbi50aGVtZXMgDSinUzIQkRrMQBltTVu_byZGZKBDTTokNDA3ZWJkZGEtYzMwYS00NzJmLWFiY2ItZTUxNjYzOGI0ODkwQgdBY2NvdW50ShD_L62KA95L8bcf54Lwf0LXUlN7InN1YiI6ImZiZGIyNjQ5LWUzMjctNDkwNy04ZjY3LTkwOGQyNGNmZDdlMyIsImlzcyI6Imh0dHBzOi8vYWNjb3VudHMuc2hvcGlmeS5jb20ifWIQ9JXN4zO-R9GN8r5UoxH4y2oQxuZkRHl4TiGQyRrakuDGnRJA7BSSeOZBgt3pX2uRbSlMZWRhPDXNtew5xr-GHR947i6XacxmhCd29bvZvjCCMUK5ITO4sZd5Nmd7T7-jHyITCw --sfr atkn_CqMCCNCr3qwGEPDj3qwGYpQCCAESEJHDg4xstkAyqcNyOeN39kwaPmh0dHBzOi8vYXBpLnNob3BpZnkuY29tL2F1dGgvc2hvcC5zdG9yZWZyb250LXJlbmRlcmVyLmRldnRvb2xzINhSKKdTOiQ0MDdlYmRkYS1jMzBhLTQ3MmYtYWJjYi1lNTE2NjM4YjQ4OTBCB0FjY291bnRKEP8vrYoD3kvxtx_ngvB_QtdSU3sic3ViIjoiZmJkYjI2NDktZTMyNy00OTA3LThmNjctOTA4ZDI0Y2ZkN2UzIiwiaXNzIjoiaHR0cHM6Ly9hY2NvdW50cy5zaG9waWZ5LmNvbSJ9YhD0lc3jM75H0Y3yvlSjEfjLahDG5mREeXhOIZDJGtqS4MadEkB7cD3vJ8X7oTOigcu1q4FOKSxt_rj2N-gcY26uMNYeRzgbELqsfnl5MeiWLRAXZRwVyrZRt63WnwQtzNoq-mwA
  · Working directory: /Users/baymax/Desktop/vscode/amiro

2024-01-05T05:41:30.960Z: Request to https://amirobeauty-com.myshopify.com/admin/api/unstable/themes.json?fields=id%2Cname%2Crole%2Cprocessing completed in 184652 ms
With response headers:

    
╭─ error ──────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  request to https://amirobeauty-com.myshopify.com/admin/api/unstable/themes  │
│  .json?fields=id%2Cname%2Crole%2Cprocessing failed, reason: read ETIMEDOUT   │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

2024-01-05T05:41:31.056Z: Unable to log analytics event - no information on executed command
2024-01-05T05:41:31.063Z: Reporting handled error to Bugsnag: request to https://amirobeauty-com.myshopify.com/admin/api/unstable/themes.json?fields=id%2Cname%2Crole%2Cprocessing failed, reason: read ETIMEDOUT
2024-01-05T05:41:31.088Z: Obtaining the dependency manager in directory /Users/baymax/Desktop/vscode/amiro...
    FetchError: request to 
    https://amirobeauty-com.myshopify.com/admin/api/unstable/themes.json?fields=id%2Cname%2Crole%2Cprocessing failed, 
    reason: read ETIMEDOUT
    Code: ETIMEDOUT

Reproduction steps

shopify theme dev -t=162423603516 -s=amirobeauty-com --verbose

Operating System

macOS Sonoma 14.1.2

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

3.51.2

Shell

zsh

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

v21.4.0

What language and version are you using in your application?

No response

@forwells
Copy link

forwells commented Jan 6, 2024

Find some wrong things, This problem caused by country firewall , in some country (cn), you can't visit shopify resource now, after 1.4 or 1.5 of 2024
.
by view shopify cli core code , it's use oclif/core package of npm to run cli command , and send some api requests by node-fetch lib, but node-fetch cannot proxy terminal requests auto, even you has open some proxy node to view shopify, so just wait shopify cli update , or change the cli core code to proxy request!
for every one , the issue has bothered me all day....

----------------------------240106 update

Yes, I'm sure the answer is right above, after test ,

Suggest Shopify CLI add --proxy and alias -p option for command option, or use terminal http_proxy or https_proxy directly, we will use proxy self!

This problem has been temporarily solved, and I feel a little more relaxed now. I can't imagine how painful it will be if you can't use shopify for local development.

@MyBaymax
Copy link
Author

MyBaymax commented Jan 7, 2024

感谢您的帮忙。您太棒了!👍
的确,无法使用shopify-cli开发非常痛苦,目前我使用theme-kit代替工作。
现在只能等待Shopify-cli添加proxy选项吗?是否有别的方法可以让我现在就可以使用shopify-cli?

Thank you for your help. You're amazing!👍
Indeed, the inability to develop using Shopify cli is very painful, and currently I am using theme kit instead of work.
Can we only wait for Shopify cli to add the proxy option now? Is there any other way for me to use Shopify cli now?

@NickOpen
Copy link

NickOpen commented Jan 7, 2024

@forwells I think you are right, this issue drive me ( and my partner ) nuts. now it's fixed by terminal http_proxy or https_proxy.

And also, under CMCC network (in China) also have some api request hang issues, we change from CMCC to Telecom before, hope this info can help other domestic bro.

@MyBaymax
Copy link
Author

MyBaymax commented Jan 8, 2024

@NickOpen 你的Shopify-cli可以正常工作了吗?是的话,可以跟我分享下你的 http_proxy or https_proxy 是怎么设置的吗?我不知道怎么通过设置这个解决问题。感谢🙏

@Shenr1
Copy link

Shenr1 commented Jan 8, 2024

@NickOpen 你的Shopify-cli可以正常工作了吗?是的话,可以跟我分享下你的 http_proxy or https_proxy 是怎么设置的吗?我不知道怎么通过设置这个解决问题。感谢🙏

遇到了同样的问题,有解决方案了吗

@forwells
Copy link

forwells commented Jan 8, 2024

@MyBaymax , @Shenr1 do a temporarily resolve plan, make these change :

in your global npm/yarn/pnpm package directory, find the package path:
node_modules/@shopify/cli-kit/dist/public/node/http.js

then:

export async function fetch(url, init) {
console.log('termial proxy')
const proxy_url = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
const agent = new HttpsProxyAgent(proxy_url)
return runWithTimer('cmd_all_timing_network_ms')(() => debugLogResponseInfo({ url: url.toString(), request: nodeFetch(url, { ...init, agent }) }));
}

before add agent to node-fetch, please make sure install https-proxy-agent package global installed, have fun day!

@NickOpen
Copy link

NickOpen commented Jan 8, 2024

@MyBaymax @Shenr1 we fixed it by C-l-a-s-hX (advanced mode) and run the terminal command to set https_proxy and http_proxy, but now it seems the repository has gone. So I just suggest you can try the @forwells supplied solution, if still have some issue, please give me private message.

@MyBaymax
Copy link
Author

MyBaymax commented Jan 8, 2024

@MyBaymax , @Shenr1 do a temporarily resolve plan, make these change :

in your global npm/yarn/pnpm package directory, find the package path: node_modules/@shopify/cli-kit/dist/public/node/http.js

then:

export async function fetch(url, init) { console.log('termial proxy') const proxy_url = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; const agent = new HttpsProxyAgent(proxy_url) return runWithTimer('cmd_all_timing_network_ms')(() => debugLogResponseInfo({ url: url.toString(), request: nodeFetch(url, { ...init, agent }) })); }

before add agent to node-fetch, please make sure install https-proxy-agent package global installed, have fun day!

非常感谢 @forwells 提供的方案 🙏。我使用@forwells提供的方案后,已可以正常使用Shopify-cli。
我将关闭该问题。期待 Shopify 团队提供 proxy 配置选项。

Thank you very much for the solution provided by @forwells 🙏. After using the solution provided by @forwells, I can now use Shopify cli normally.
I will close this issue. Looking forward to the Shopify team providing proxy configuration options. 🎉

@MyBaymax MyBaymax closed this as completed Jan 8, 2024
@Shenr1
Copy link

Shenr1 commented Jan 9, 2024 via email

@wantgoworld
Copy link

I am using vpn proxy, http proxy local port is 10808 LAN port is 10810, no environment variables are set, here is the code I changed:
屏幕截图 2024-01-09 110349
Is something misconfigured?

@MyBaymax
Copy link
Author

MyBaymax commented Jan 9, 2024

@Shenr1 @wantgoworld 可以发下你们终端输出的信息,以便确认错误原因

@wantgoworld
Copy link

╭─ error ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ request to https://admin.myshopify.com/admin/api/unstable/themes/xxxx.json?fields=id%2Cprocessing failed, reason: Client network │
│ socket disconnected before secure TLS connection was established │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

FetchError: request to https://admin.myshopify.com/admin/api/unstable/themes/xxxxx.json?fields=id%2Cprocessing failed, reason: Client network socket disconnected before secure TLS connection was established
Code: ECONNRESET

@MyBaymax
Copy link
Author

MyBaymax commented Jan 9, 2024

@wantgoworld 如果你的终端没有打印 termail proxy, 则说明你的在vscode中执行的 shopify-cli 并非你修改的 fetch 位置

@wantgoworld
Copy link

@wantgoworld 如果你的终端没有打印 termail proxy, 则说明你的在vscode中执行的 shopify-cli 并非你修改的 fetch 位置

找到问题了。谢谢

@Shenr1
Copy link

Shenr1 commented Jan 9, 2024 via email

@MyBaymax
Copy link
Author

MyBaymax commented Jan 9, 2024

@Shenr1 你这代码看了太难受了,可以处理下格式吗😣

@kuww
Copy link

kuww commented Jan 9, 2024

@MyBaymax 按照上面的方案 去修改http.js的代码,可以获取到json文件,但是ssl失败了
image
你遇到了没

@MyBaymax
Copy link
Author

MyBaymax commented Jan 9, 2024

@MyBaymax 按照上面的方案 去修改http.js的代码,可以获取到json文件,但是ssl失败了 image 你遇到了没

我没有遇到这个问题

@kuww
Copy link

kuww commented Jan 9, 2024

@MyBaymax image
请问是这样修改的吗

@MyBaymax
Copy link
Author

MyBaymax commented Jan 9, 2024

@MyBaymax image 请问是这样修改的吗

是的,还需要导入 HttpsProxyAgent

@halweg
Copy link

halweg commented Jan 9, 2024

my node.js version is v20.9.0,
and i changed the gobal node_modules code like this:
企业微信截图_20240109185857
and then, report this:
企业微信截图_20240109190003

@MyBaymax
Copy link
Author

MyBaymax commented Jan 9, 2024

my node.js version is v20.9.0, and i changed the gobal node_modules code like this: 企业微信截图_20240109185857 and then, report this: 企业微信截图_20240109190003

HttpsProxyAgent 导入错了

import { HttpsProxyAgent } from "https-proxy-agent";

@MyBaymax
Copy link
Author

MyBaymax commented Jan 9, 2024

给大家写下具体步骤

完整Shopify-cli代理设置步骤

Step1: 确认文件位置

例如我是使用 brew 安装的,可以通过 brew list shopify-cli 确认Shopify-cli 文件位置

baymax@chouyaofandedeMacBook-Pro remix-shopify % brew list shopify-cli
/usr/local/Cellar/shopify-cli/3.53.0/bin/shopify
/usr/local/Cellar/shopify-cli/3.53.0/libexec/bin/ (2 files)
/usr/local/Cellar/shopify-cli/3.53.0/libexec/lib/ (57641 files)

Step2: 进入theme@shopify/cli-kit 中安装 https-proxy-agent

例如我的完整路径 node_modules/@shopify/theme/node_modules/@shopify/cli-kit, 如果你要用theme 外其他命令,还需要修改 cli 中的@shopify/cli-kit

安装 https-proxy-agent

npm install https-proxy-agent

Step3: 修改 dist/public/node/http.js 文件中的fetch 函数

import { HttpsProxyAgent } from "https-proxy-agent";

export async function fetch(url, init) {
  // 可以保留 console.log("fetching: Proxy"); 以确认你修改的路径是否正确
  console.log("fetching: Proxy");
  // 可以用变量,也可以直接写代理地址
  // const proxy_url = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; 
  const proxy_url = "http://127.0.0.1:10010";
  const agent = new HttpsProxyAgent(proxy_url);
  return runWithTimer("cmd_all_timing_network_ms")(() =>
    debugLogResponseInfo({
      url: url.toString(),
      request: nodeFetch(url, { ...init, agent }),
    })
  );
}

÷

@CharlieLu2022
Copy link

非常感谢,按以上具体方法问题已解决!!

@Shenr1
Copy link

Shenr1 commented May 9, 2024

Author

我重装了cli ,修改了http.js文件,文件可以确定没错但是不走fetch方法,麻烦看看是什么原因,感激不尽!

@EdmondWang
Copy link

Try add https agent to shopifyFetch() methd in the http.js as well.

@Shenr1
Copy link

Shenr1 commented May 9, 2024

Try add https agent to shopifyFetch() methd in the http.js as well.

Can you show me the modified code? Thank you very much!

@lizhenmiao
Copy link

@zhengcheng123 昨天开始又出现了这个问题 image

我重装了cli ,修改了http.js文件,文件可以确定没错但是不走fetch方法,麻烦看看是什么原因,感激不尽!

Current Shopify CLI version: 3.51.2当前 Shopify CLI 版本:3.51.2 ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x64-mingw-ucrt]ruby 3.2.3(2024-01-18 修订版 52bb2ac0a6)[x64-mingw-ucrt]

你有解决吗? 我也碰到相似的问题了

@MyBaymax
Copy link
Author

@Shenr1 , @lizhenmiao 你可以试下将shopify更新至 v3.56.3,我当前使用的是该版本,可正常使用。
v3.56.3 的修改代码如下,同样是给 fetch 请求加代理

export default async function fetch(url, options_) {
  const proxy_url = "http://127.0.0.1:10010";
  const agent = new HttpsProxyAgent(proxy_url);
  options_.agent = agent;
  ....
}

@lizhenmiao
Copy link

@Shenr1 , @lizhenmiao 你可以试下将shopify更新至 v3.56.3,我当前使用的是该版本,可正常使用。 v3.56.3 的修改代码如下,同样是给 fetch 请求加代理

export default async function fetch(url, options_) {
  const proxy_url = "http://127.0.0.1:10010";
  const agent = new HttpsProxyAgent(proxy_url);
  options_.agent = agent;
  ....
}

非常感谢, 我现在使用 proxifier 暂时可以使用了. 请问你们有交流群吗, 有的话能分享一下吗?

我使用的 MAC, 本来想重装一下 shopify-cli 试试, 然后使用 brew install shopify-cli 安装的为最新版本的3.60.0, 我不知道要怎么安装指定版本的 shopify-cli, 并且我找到 shopify-cli 的目录之后发现文件内容跟之前的路径不一样

@MyBaymax
Copy link
Author

给大家更新下@shopify/cli v3.60.0 的代理设置方案

  1. 找到 @Shopify 。不同安装方式的路径不同,怎么找可以看上文
  2. 用vscode打开 @Shopify 文件夹。
  3. 全局搜索 ../cli-kit/src/public/node/http.ts。一共有三个,第三个就是我们要修改的位置
  4. 修改fetch2shopifyFetch函数, 完整代码如下
// 引入 HttpsProxyAgent, 可以在 cli 目录下安装 https-proxy-agent
import { HttpsProxyAgent } from "https-proxy-agent";
// ....
// 修改函数
async function fetch2(url2, init) {
  const proxy_url = "http://127.0.0.1:10010";
  const agent = new HttpsProxyAgent(proxy_url);
  return runWithTimer("cmd_all_timing_network_ms")(
    () => debugLogResponseInfo({ url: url2.toString(), request: fetch(url2, { ...init, 
      agent}) })
  );
}

async function shopifyFetch(url2, init) {
  const proxy_url = "http://127.0.0.1:10010";
  const agent = new HttpsProxyAgent(proxy_url);

  const sanitizedUrl = sanitizeURL(url2.toString());
  
  const options = {
    agent,
    ...init ?? {},
    headers: {
      ...await buildHeaders(),
      ...init?.headers ?? {}
    }
  };

  outputDebug(outputContent`Sending ${options.method ?? "GET"} request to URL ${sanitizedUrl}
With request headers:
${sanitizedHeadersOutput(options?.headers ?? {})}
`);
  return runWithTimer("cmd_all_timing_network_ms")(async () => {
    return debugLogResponseInfo({ url: url2.toString(), request: fetch(url2, { ...init, agent }) });
  });
}

@Guo8a
Copy link

Guo8a commented May 21, 2024

使用 graphql-codegen --config codegen.yml 报错:

      Failed to load schema from https://78d5bf-fb.myshopify.com/api/2024-04/graphql.json:
      Client network socket disconnected before secure TLS connection was established
      Error: Client network socket disconnected before secure TLS connection was established
      at connResetException (node:internal/errors:705:14)
      at TLSSocket.onConnectEnd (node:_tls_wrap:1594:19)
      at TLSSocket.emit (node:events:525:35)
      at endReadableNT (node:internal/streams/readable:1358:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)
      GraphQL Code Generator supports:
      - ES Modules and CommonJS exports (export as default or named export "schema")
      - Introspection JSON File
      - URL of GraphQL endpoint
      - Multiple files with type definitions (glob expression)
      - String in config file
      Try to use one of above options and run codegen again.

有人遇到类似的问题吗

@Guo8a
Copy link

Guo8a commented May 21, 2024

使用 graphql-codegen --config codegen.yml 报错:

      Failed to load schema from https://78d5bf-fb.myshopify.com/api/2024-04/graphql.json:
      Client network socket disconnected before secure TLS connection was established
      Error: Client network socket disconnected before secure TLS connection was established
      at connResetException (node:internal/errors:705:14)
      at TLSSocket.onConnectEnd (node:_tls_wrap:1594:19)
      at TLSSocket.emit (node:events:525:35)
      at endReadableNT (node:internal/streams/readable:1358:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)
      GraphQL Code Generator supports:
      - ES Modules and CommonJS exports (export as default or named export "schema")
      - Introspection JSON File
      - URL of GraphQL endpoint
      - Multiple files with type definitions (glob expression)
      - String in config file
      Try to use one of above options and run codegen again.

有人遇到类似的问题吗

我换了一种方式,在 NextJs 中使用 fetch 来获取 ShopifyData:

const domain = process.env.SHOPIFY_STORE_DOMAIN;
const storefrontAccessToken = process.env.SHOPIFY_STOREFRONT_ACCESSTOKEN;

async function ShopifyData(query) {
  const URL = `https://${domain}/api/2024-04/graphql.json`;

  const options = {
    endpoint: URL,
    method: "POST",
    headers: {
      "X-Shopify-Storefront-Access-Token": storefrontAccessToken,
      Accept: "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ query }),
  };

  try {
    const data = await fetch(URL, options).then((response) => {
      return response.json();
    });

    return data;
  } catch (error) {
    console.dir(error);
    throw new Error("Products not fetched");
  }
}

同样报和 TLS 相关的错:

FetchError: request to https://***.myshopify.com/api/2024-04/graphql.json failed, reason: Client network socket disconnected before secure TLS connection was established
    at ClientRequest.<anonymous> (/Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/node-fetch/lib/index.js:1461:11)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:494:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}
Error: Products not fetched
    at ShopifyData (webpack-internal:///./lib/shopify.js:35:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getProductsInCollection (webpack-internal:///./lib/shopify.js:68:20)
    at async getStaticProps (webpack-internal:///./pages/index.js:124:20)
    at async Object.renderToHTML (/Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/render.js:374:24)
    at async doRender (/Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/next-server.js:1127:38)
    at async /Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/next-server.js:1221:28
    at async /Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/response-cache.js:60:36

@MyBaymax
Copy link
Author

MyBaymax commented May 21, 2024

@Guo8a
*.myshopify.com 对应的IP目前已被限制访问,因此需要代理。
你使用 fetch 请求可以通过 "https-proxy-agent" 来设置代理。具体怎么使用可以看 "https-proxy-agent" 的使用

@Guo8a
Copy link

Guo8a commented May 21, 2024

@MyBaymax
您好,我按照您说的,使用 htps-proxy-agent对代码进行了修改:

import { HttpsProxyAgent } from "https-proxy-agent";

const domain = process.env.SHOPIFY_STORE_DOMAIN;
const storefrontAccessToken = process.env.SHOPIFY_STOREFRONT_ACCESSTOKEN;

async function ShopifyData(query) {
  const URL = `https://${domain}/admin/api/2024-04/graphql.json`;
  const proxy_url = "http://127.0.0.1:7898";
  const agent = new HttpsProxyAgent(proxy_url, { timeout: 20000 });
  const options = {
    endpoint: URL,
    method: "POST",
    headers: {
      "X-Shopify-Storefront-Access-Token": storefrontAccessToken,
      Accept: "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ query }),
    agent: agent,
  };
  try {
    const data = await fetch(URL, options).then((response) => {
      console.dir(response);
      return response.json();
    });

    return data;
  } catch (error) {
    console.dir(error);
    throw new Error("Products not fetched");
  }
}

其中 http://127.0.0.1:7898 是我在设置命令行代理的中会设置的端口号:export https_proxy=http://127.0.0.1:7898 http_proxy=http://127.0.0.1:7898 all_proxy=socks5://127.0.0.1:7898
可是报错如下:

guoba@192 shopify-next.js-tailwind-main % npm run dev

> dev
> next dev

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /Users/guoba/Downloads/shopify-next.js-tailwind-main/.env.local
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
event - compiled successfully
event - build page: /next/dist/pages/_error
wait  - compiling...
event - compiled successfully
event - build page: /
wait  - compiling...
event - compiled successfully
TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11730:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ShopifyData (webpack-internal:///./lib/shopify.js:37:18)
    at async getProductsInCollection (webpack-internal:///./lib/shopify.js:77:20)
    at async getStaticProps (webpack-internal:///./pages/index.js:124:20)
    at async Object.renderToHTML (/Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/render.js:374:24)
    at async doRender (/Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/next-server.js:1127:38)
    at async /Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/next-server.js:1221:28
    at async /Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/response-cache.js:60:36 {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (node:internal/deps/undici/undici:6869:28)
      at node:internal/deps/undici/undici:6825:50
      at Immediate._onImmediate (node:internal/deps/undici/undici:6857:13)
      at process.processImmediate (node:internal/timers:478:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}
Error: Products not fetched
    at ShopifyData (webpack-internal:///./lib/shopify.js:44:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getProductsInCollection (webpack-internal:///./lib/shopify.js:77:20)
    at async getStaticProps (webpack-internal:///./pages/index.js:124:20)
    at async Object.renderToHTML (/Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/render.js:374:24)
    at async doRender (/Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/next-server.js:1127:38)
    at async /Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/next-server.js:1221:28
    at async /Users/guoba/Downloads/shopify-next.js-tailwind-main/node_modules/next/dist/server/response-cache.js:60:36

不知道您是否遇到过这种情况?或者我的使用是否正确

@Guo8a
Copy link

Guo8a commented May 22, 2024

给大家更新下@shopify/cli v3.60.0 的代理设置方案

  1. 找到 @Shopify 。不同安装方式的路径不同,怎么找可以看上文
  2. 用vscode打开 @Shopify 文件夹。
  3. 全局搜索 ../cli-kit/src/public/node/http.ts。一共有三个,第三个就是我们要修改的位置
  4. 修改fetch2shopifyFetch函数, 完整代码如下
// 引入 HttpsProxyAgent, 可以在 cli 目录下安装 https-proxy-agent
import { HttpsProxyAgent } from "https-proxy-agent";
// ....
// 修改函数
async function fetch2(url2, init) {
  const proxy_url = "http://127.0.0.1:10010";
  const agent = new HttpsProxyAgent(proxy_url);
  return runWithTimer("cmd_all_timing_network_ms")(
    () => debugLogResponseInfo({ url: url2.toString(), request: fetch(url2, { ...init, 
      agent}) })
  );
}

async function shopifyFetch(url2, init) {
  const proxy_url = "http://127.0.0.1:10010";
  const agent = new HttpsProxyAgent(proxy_url);

  const sanitizedUrl = sanitizeURL(url2.toString());
  
  const options = {
    agent,
    ...init ?? {},
    headers: {
      ...await buildHeaders(),
      ...init?.headers ?? {}
    }
  };

  outputDebug(outputContent`Sending ${options.method ?? "GET"} request to URL ${sanitizedUrl}
With request headers:
${sanitizedHeadersOutput(options?.headers ?? {})}
`);
  return runWithTimer("cmd_all_timing_network_ms")(async () => {
    return debugLogResponseInfo({ url: url2.toString(), request: fetch(url2, { ...init, agent }) });
  });
}

我按照这个教程:https://shopify.dev/docs/custom-storefronts/hydrogen/getting-started,尝试运行项目,运行 npm run dev,是可以运行的。
但是我想 Link Hydrogen project to Shopify,运行npx shopify hydrogen link后,报错如下:
image
于是按照您的方法设置代理:

  1. 在项目内的 node_modules 文件夹下找到 @shopify 文件夹,用 VSCode 打开
  2. 全局搜索 // ../cli-kit/src/public/node/http.ts,然后修改第三个:
    image
    image

这里我尝试过设置proxy_url = "http://127.0.0.1:7898"或proxy_url = "http://127.0.0.1:10010"

3.尝试重新运行npx shopify hydrogen link

经过改动,依然会报错 reason: Client network socket disconnected before secure TLS connection was established,请问是否有任何地方做得不妥?
十分感谢,best regards。

@MyBaymax
Copy link
Author

@Guo8a
“其中 http://127.0.0.1:7898 是我在设置命令行代理的中会设置的端口号:export https_proxy=http://127.0.0.1:7898 http_proxy=http://127.0.0.1:7898 all_proxy=socks5://127.0.0.1:7898”

感觉你对代理地址好像存在误解。代理地址并不是指你手动设置的环境变量http_proxy。正确的代理地址是只你VPN启用的代理地址。你应该通过你使用的代理软件查看代理,或者查看网络适配器中的代理地址

@Guo8a
Copy link

Guo8a commented May 22, 2024

@Guo8a “其中 http://127.0.0.1:7898 是我在设置命令行代理的中会设置的端口号:export https_proxy=http://127.0.0.1:7898 http_proxy=http://127.0.0.1:7898 all_proxy=socks5://127.0.0.1:7898”

感觉你对代理地址好像存在误解。代理地址并不是指你手动设置的环境变量http_proxy。正确的代理地址是只你VPN启用的代理地址。你应该通过你使用的代理软件查看代理,或者查看网络适配器中的代理地址

image
image
目前是这样的。

@MyBaymax
Copy link
Author

@gua8a
哦,你npm run dev已经可以正常使用了。那么也就是说明你的修改是正确的,npx shopify hydrogen link 请求失败,那就说明其没有走代理,其运行的请求方法并非上述位置。我没去研究过这个,需要你自己研究下它的请求方法是哪个,然后给他配置代理。

@Guo8a
Copy link

Guo8a commented May 22, 2024

@gua8a 哦,你npm run dev已经可以正常使用了。那么也就是说明你的修改是正确的,npx shopify hydrogen link 请求失败,那就说明其没有走代理,其运行的请求方法并非上述位置。我没去研究过这个,需要你自己研究下它的请求方法是哪个,然后给他配置代理。

十分百分千分万分感谢您的耐心指导。
示例项目( hydrogen-quickstart )在我npm run dev的时候全部配置应该都是默认的,没有进行网络请求,所以运行才不会报错。
我猜测,然后到 npx shopify hydrogen link的时候,同样会进入 cli 的 fetch 方法,所以才会有 TLS 的报错。

再次感谢大佬,可否再留个联系方式交流下问题,不胜感激。

@MyBaymax
Copy link
Author

@gua8a 哦,你npm run dev已经可以正常使用了。那么也就是说明你的修改是正确的,npx shopify hydrogen link 请求失败,那就说明其没有走代理,其运行的请求方法并非上述位置。我没去研究过这个,需要你自己研究下它的请求方法是哪个,然后给他配置代理。

十分百分千分万分感谢您的耐心指导。 示例项目( hydrogen-quickstart )在我npm run dev的时候全部配置应该都是默认的,没有进行网络请求,所以运行才不会报错。 我猜测,然后到 npx shopify hydrogen link的时候,同样会进入 cli 的 fetch 方法,所以才会有 TLS 的报错。

再次感谢大佬,可否再留个联系方式交流下问题,不胜感激。

微信 abc939039210

@senher
Copy link

senher commented Jun 1, 2024

我这出现奇怪的问题
在 node_modules@shopify\cli 下,npm i https-proxy-agent安装的时候报错了
image

@zqian7531
Copy link

我通过brew 安装的shopify-cli 3.60.1,它的目录结构似乎发生了变化,不再有http.ts文件,而是需要修改/usr/local/Cellar/shopify-cli/3.60.1/libexec/lib/node_modules/@shopify/cli/dist/chunk-BKLNHG3A.js(具体目录依据安装路径和安装版本)。

  1. 在/usr/local/Cellar/shopify-cli/3.60.1/libexec/lib/node_modules/@shopify/cli下 执行 npm install https-proxy-agent
  2. 在chunk-BKLNHG3A.js中,
  • 引入 import { HttpsProxyAgent } from "https-proxy-agent";
  • 修改fetch2 和 shopifyFetch

@narutopden
Copy link

Hi, I am also a Shopify-cli user based in china I haven't set up any proxy and am facing this problem. can any one tell me how to set up the proxy?

@yeonlala
Copy link

Hi, I am also a Shopify-cli user based in china I haven't set up any proxy and am facing this problem. can any one tell me how to set up the proxy?你好,我也是一名位于中国的 Shopify-cli 用户,我没有设置任何代理,但遇到了这个问题。谁能告诉我如何设置代理?

其实就是设置个全局代理即可。无需改任何代码

@feifeirun97
Copy link

我通过brew 安装的shopify-cli 3.63.2,已经没有httpjs文件了。

@feifeirun97
Copy link

Hi, I am also a Shopify-cli user based in china I haven't set up any proxy and am facing this problem. can any one tell me how to set up the proxy?你好,我也是一名位于中国的 Shopify-cli 用户,我没有设置任何代理,但遇到了这个问题。谁能告诉我如何设置代理?

其实就是设置个全局代理即可。无需改任何代码

老哥指导下怎么操作?

@ListKerHe
Copy link

@gua8a 哦,你npm run dev已经可以正常使用了。那么也就是说明你的修改是正确的,npx shopify hydrogen link 请求失败,那就说明其没有走代理,其运行的请求方法并非上述位置。我没去研究过这个,需要你自己研究下它的请求方法是哪个,然后给他配置代理。

十分百分千分万分感谢您的耐心指导。 示例项目( hydrogen-quickstart )在我npm run dev的时候全部配置应该都是默认的,没有进行网络请求,所以运行才不会报错。 我猜测,然后到 npx shopify hydrogen link的时候,同样会进入 cli 的 fetch 方法,所以才会有 TLS 的报错。

再次感谢大佬,可否再留个联系方式交流下问题,不胜感激。

@Guo8a 哥我遇到的是和你一样的问题,哥你是怎么解决的呀,我也是能run dev,但是npx shopify hydrogen link报错了,我想咨询下怎么去解决

@ListKerHe
Copy link

奇怪

你这问题咋解决的哥

@Zardw
Copy link

Zardw commented Sep 26, 2024

用VPN

@omgcx1222
Copy link

@MyBaymax , @Shenr1 do a temporarily resolve plan, make these change :
in your global npm/yarn/pnpm package directory, find the package path: node_modules/@shopify/cli-kit/dist/public/node/http.js
then:
export async function fetch(url, init) { console.log('termial proxy') const proxy_url = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; const agent = new HttpsProxyAgent(proxy_url) return runWithTimer('cmd_all_timing_network_ms')(() => debugLogResponseInfo({ url: url.toString(), request: nodeFetch(url, { ...init, agent }) })); }
before add agent to node-fetch, please make sure install https-proxy-agent package global installed, have fun day!

非常感谢 @forwells 提供的方案 🙏。我使用@forwells提供的方案后,已可以正常使用Shopify-cli。 我将关闭该问题。期待 Shopify 团队提供 proxy 配置选项。

Thank you very much for the solution provided by @forwells 🙏. After using the solution provided by @forwells, I can now use Shopify cli normally. I will close this issue. Looking forward to the Shopify team providing proxy configuration options. 🎉

你好,我现在也遇到了这个问题,同样的install了https-proxy-agent,修改了
export async function fetch(url, init) {
console.log(111);
const proxy_url = "http://127.0.0.1:7890"
const agent = new HttpsProxyAgent(proxy_url)
return runWithTimer('cmd_all_timing_network_ms')(() => debugLogResponseInfo({ url: url.toString(), request: nodeFetch(url, {...init, agent}) }));
}
执行shopify theme dev --store hqy-infant,提示:
request to https://hqy-infant.myshopify.com/admin/api/unstable/themes.json failed, reason: read ECONNRESET
并没有 console.log 输出 111

但是修改之前提示的是reason: Client network socket disconnected before secure TLS connection was established

我该如何解决?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: @shopify/theme @shopify/theme package issues Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests