Repository navigation
fix: SDK failed to load on non-UTF-8 pages; version 19.4.1 - #206
Merged
Merged
Conversation
19.4.0 added a regex with raw combining characters. The CDN serves the script without a charset, so a page that isn't UTF-8 decodes it with its own encoding, the regex becomes invalid and the whole bundle throws at load. Escape the range in the source and make the build ASCII-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since 19.4.0 (live on
sdk.gleap.io/latestsince 2026-11-06 ~08:18Z), the SDK throws at load on any page that isn't UTF-8, sowindow.Gleapstays undefined and the widget doesn't appear:normalizeLabelinsrc/GleapHighlight.js(added in #204) has a regex with raw combining characters. The CDN sendscontent-type: application/javascriptwith no charset, so the browser decodes the script with the page's encoding. On those pages the character range becomes invalid and the whole bundle fails to parse.Fix
src/GleapHighlight.js: write the range as̀-ͯ.webpack.config.js: set Terser'sascii_only: true, so no non-ASCII character can reach a bundle again. This also stops other text in the bundle from being garbled on those pages. The bundle grows by about 0.01%.build/andpublished/.Checked
Real Chromium, with the page's characters decoded by the browser:
GleapGleapGleap.initializeandGleap.open()ran and the messenger rendered, with no page errors.build/browser,build/cjs,build/esm,build/embedorpublished/19.4.1.npm test: 36 suites, 612 tests pass.No regression test added, per the workspace rule on tests for core code only.
Not done or not known
ascii_onlyit no longer matters for this bundle, so I left it alone.published/_headerscould add one later if wanted.Rollout
Merging to master deploys to the CDN through Cloudflare Workers Builds, including
latest. npm needs the19.4.1tag pushed after that. Neither has been done.🤖 Generated with Claude Code