Skip to content

Comments

Fix hot-reloading for the {% javascript %} tag when serving compiled assets scripts with multibyte characters#6853

Merged
karreiro merged 1 commit intomainfrom
fix-javacript-hotreloading
Feb 13, 2026
Merged

Fix hot-reloading for the {% javascript %} tag when serving compiled assets scripts with multibyte characters#6853
karreiro merged 1 commit intomainfrom
fix-javacript-hotreloading

Conversation

@karreiro
Copy link
Contributor

WHY are these changes introduced?

When hot-reloading compiled JS generated from {% javascript %} blocks, the response Content-Length header could be computed using the string character count rather than the UTF‑8 byte length. This becomes incorrect as soon as the output contains multi-byte characters (e.g., an em dash ).

WHAT is this pull request doing?

This PR updates the compiled_assets script response path to set content-length based on the UTF‑8 byte length.

How to test your changes?

  • Run shopify theme dev with a snippet like this:
Hey
{% javascript %}
console.log("Hey, hey")
// ...not full cart — derive count from response

console.log("Hey, hey, heeeey!")
{% endjavascript %}

Post-release steps

n/a

Measuring impact

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@karreiro karreiro requested review from a team as code owners February 12, 2026 08:28
Copy link
Contributor

@frandiox frandiox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maaakes sense, thanks!

@karreiro
Copy link
Contributor Author

👋 Hey @Shopify/app-inner-loop, could you please take a look at this when you have a moment?

PS: I've proposed #6818 to prevent similar review requests in the future 🙇

@github-actions
Copy link
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.9% 14554/18446
🟡 Branches 73.23% 7223/9863
🟡 Functions 79.09% 3704/4683
🟡 Lines 79.25% 13761/17364

Test suite run success

3772 tests passing in 1453 suites.

Report generated by 🧪jest coverage report action from 6a7bfce

@karreiro karreiro added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit da3a512 Feb 13, 2026
25 checks passed
@karreiro karreiro deleted the fix-javacript-hotreloading branch February 13, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants