Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

App embedded extension - theme-check-disable AssetSizeJavaScript not working #740

Closed
ricardobrg opened this issue Aug 4, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@ricardobrg
Copy link

Describe the bug
Trying to load an asset >10kb in liquid by disabling AssetSizeJavaScript with the following code:

{% # theme-check-disable AssetSizeJavaScript %}
<script async src="https://unpkg.com/@mytiki/tiki-sdk-js@2.1.4/dist/index.js"></script>
{% # theme-check-enable AssetSizeJavaScript %}"

But theme check still throws an Exception when running npm run deploy

Command failed with exit code 2: bundle exec theme-check C:/Users/ricar/dev/tiki-shopify/extensions/theme-block -C
:theme_app_extension
Checking C:/Users/ricar/dev/tiki-shopify/extensions/theme-block ...
Exception while running `AssetSizeJavaScript#on_script`:

Expected
AssetSizeJavaScript check should be disabled for that line and the extension should be published.

Actual
The AssetSizeJavaScript check throws an Exception, interrupting the deployment script.

Stack trace

 theme_extensions │ Exception while running `AssetSizeJavaScript#on_script`:
 theme_extensions │ 
 theme_extensions │ Timeout::Error: execution expired
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1271:in `initialize'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1271:in `open'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1271:in `block in connect'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:189:in `block in timeout'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:196:in `timeout'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1269:in `connect'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1248:in `do_start'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1237:in `start'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:687:in `start'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/remote_asset_file.
                    rb:48:in `request'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/remote_asset_file.
                    rb:34:in `content'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/remote_asset_file.
                    rb:42:in `gzipped_size'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks/asset_size_
                    javascript.rb:38:in `src_to_file_size'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks/asset_size_
                    javascript.rb:19:in `on_script'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:42:in
                    `block in call_check_method'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:189:in `block in timeout'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:36:in `block in catch'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:36:in `catch'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:36:in `catch'
 theme_extensions │   C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:198:in `timeout'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:41:in
                    `call_check_method'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:11:in
                    `block in call'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:10:in
                    `each'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:10:in
                    `call'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:32
                    :in `call_checks'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:23
                    :in `visit'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:24
                    :in `block in visit'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:24
                    :in `each'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:24
                    :in `visit'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:14
                    :in `visit_liquid_file'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:55:in
                    `block (2 levels) in analyze_theme'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:52:in
                    `each'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:52:in
                    `each_with_index'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:52:in
                    `block in analyze_theme'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check.rb:68:in
                    `with_liquid_c_disabled'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:51:in
                    `analyze_theme'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/cli.rb:198:in
                    `check'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/cli.rb:128:in
                    `run!'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/cli.rb:132:in
                    `run'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/cli.rb:154:in
                    `parse_and_run'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/exe/theme-check:6:in `<top
                    (required)>'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/bin/theme-check:25:in `load'
 theme_extensions │   C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/bin/theme-check:25:in `<main>'
 theme_extensions │ ```
 theme_extensions │
 theme_extensions │ Theme File: `blocks/tiki.liquid`
 theme_extensions │ Node: `String`
 theme_extensions │ Markup:
 theme_extensions │ ```
 theme_extensions │ <script async src="https://unpkg.com/@mytiki/tiki-sdk-js@2.1.4/dist/index.js">
 theme_extensions │ ```
 theme_extensions │ Line number: 23
 theme_extensions │ Check options: `{:threshold_in_bytes=>10000}
 theme_extensions │ `
 theme_extensions │ Theme Check Version: 1.15.0
 theme_extensions │ Ruby Version: 3.2.2
 theme_extensions │ Platform: x64-mingw-ucrt
 theme_extensions │ Muffin mode: activated
 theme_extensions │
 theme_extensions │ ------------------------
 theme_extensions │ Whoops! It looks like you found a bug in Theme Check.
 theme_extensions │ Please report it at https://github.com/Shopify/theme-check/issues, and include the message above.
 theme_extensions │ Or cross your fingers real hard, and try again.

── external error ──────────────────────────────────────────────────────────────────

Error coming from `bundle exec theme-check C:/Users/ricar/dev/tiki-shopify/extensions/theme-block -C :theme_app_extension`     

Command failed with exit code 2: bundle exec theme-check C:/Users/ricar/dev/tiki-shopify/extensions/theme-block -C
:theme_app_extension
Checking C:/Users/ricar/dev/tiki-shopify/extensions/theme-block ...
Exception while running `AssetSizeJavaScript#on_script`:
Timeout::Error: execution expired
  C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1271:in `initialize'
  C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1271:in `open'
  C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1271:in `block in connect'
  C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:189:in `block in timeout'
  C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:196:in `timeout'
  C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1269:in `connect'
  C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1248:in `do_start'
  C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:1237:in `start'
  C:/Ruby32-x64/lib/ruby/3.2.0/net/http.rb:687:in `start'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/remote_asset_file.r
b:48:in `request'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/remote_asset_file.r
b:34:in `content'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/remote_asset_file.r
b:42:in `gzipped_size'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks/asset_size_j
avascript.rb:38:in `src_to_file_size'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks/asset_size_j
avascript.rb:19:in `on_script'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:42:in    
`block in call_check_method'
  C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:189:in `block in timeout'
  C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:36:in `block in catch'
  C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:36:in `catch'
  C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:36:in `catch'
  C:/Ruby32-x64/lib/ruby/3.2.0/timeout.rb:198:in `timeout'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:41:in    
`call_check_method'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:11:in    
`block in call'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:10:in    
`each'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/checks.rb:10:in    
`call'

C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:32:in
 `call_checks'

C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:23:in
 `visit'

C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:24:in
 `block in visit'

C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:24:in
 `each'

C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:24:in
 `visit'

C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/html_visitor.rb:14:in
 `visit_liquid_file'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:55:in  
`block (2 levels) in analyze_theme'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:52:in  
`each'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:52:in  
`each_with_index'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:52:in  
`block in analyze_theme'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check.rb:68:in
`with_liquid_c_disabled'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/analyzer.rb:51:in  
`analyze_theme'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/cli.rb:198:in      
`check'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/cli.rb:128:in      
`run!'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/cli.rb:132:in `run'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/lib/theme_check/cli.rb:154:in      
`parse_and_run'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/theme-check-1.15.0/exe/theme-check:6:in `<top
(required)>'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/bin/theme-check:25:in `load'
  C:/Users/ricar/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/bin/theme-check:25:in `<main>'


Theme File: `blocks/tiki.liquid`
Node: `String`
Markup:

<script async src="https://unpkg.com/@mytiki/tiki-sdk-js@2.1.4/dist/index.js">

Line number: 23
Check options: `{:threshold_in_bytes=>10000}
`
Theme Check Version: 1.15.0
Ruby Version: 3.2.2
Platform: x64-mingw-ucrt
Muffin mode: activated

------------------------
Whoops! It looks like you found a bug in Theme Check.
Please report it at https://github.com/Shopify/theme-check/issues, and include the message above.
Or cross your fingers real hard, and try again.

────────────────────────────────────────────────────────────────────────────────────

Debugging information

  • Windows 11
  • Version 9.7.2
@ricardobrg ricardobrg added the bug Something isn't working label Aug 4, 2023
@overallduka
Copy link

That's happening for me too, tried this:

  {% # theme-check-disable AssetSizeAppBlockJavaScript,AssetSizeJavaScript %}

And also tried the .theme-check.yml file and won't work:

Line number: 62
Check options: `{:threshold_in_bytes=>10000}
`
Theme Check Version: 1.15.0
Ruby Version: 2.7.5
Platform: x86_64-darwin21
Muffin mode: activated

I'm using Mac M1.

@fawaz-alesayi
Copy link

I can confirm I'm facing this too while trying to load the Sentry SDK

{% # theme-check-disable AssetSizeAppBlockJavaScript,AssetSizeJavaScript %}
<script
  src="https://js.sentry-cdn.com/READCTED.min.js"
  crossorigin="anonymous"
  defer
></script>
Line number: 2
Check options: `{:threshold_in_bytes=>10000}`
Theme Check Version: 1.15.0
Ruby Version: 3.2.2
Platform: arm64-darwin23
Muffin mode: activated

@lukeh-shopify
Copy link
Contributor

👋🏻 Hi @ricardobrg! Thanks for reporting this. Unfortunately the Ruby version of theme check has been deprecated for some time. Would you be able to confirm you are still having issues when using our maintained version of theme check? This is done using either the latest version of the Shopify CLI, or via the Shopify Liquid Visual Studio Code extension.

If you are still having issues, please raise an issue over in the CLI or theme tools repositories. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants