Skip to content

fix: SDK failed to load on non-UTF-8 pages; version 19.4.1 - #206

Merged
boehlerlukas merged 1 commit into
masterfrom
fix-sdk-ascii-only-bundle
Nov 6, 2026
Merged

boehlerlukas merged 1 commit into
masterfrom
fix-sdk-ascii-only-bundle

Conversation

@boehlerlukas

Copy link
Copy Markdown
Contributor

Problem

Since 19.4.0 (live on sdk.gleap.io/latest since 2026-11-06 ~08:18Z), the SDK throws at load on any page that isn't UTF-8, so window.Gleap stays undefined and the widget doesn't appear:

SyntaxError: Invalid regular expression: /[̀-ͯ]/g: Range out of order in character class

normalizeLabel in src/GleapHighlight.js (added in #204) has a regex with raw combining characters. The CDN sends content-type: application/javascript with 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's ascii_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%.
  • Version 19.4.1, with the changelog and rebuilt build/ and published/.

Checked

Real Chromium, with the page's characters decoded by the browser:

Bundle No charset ISO-8859-1 UTF-8
Live CDN 19.4.0 SyntaxError, no Gleap SyntaxError, no Gleap works
This PR works works works
  • On an ISO-8859-1 page with this build, Gleap.initialize and Gleap.open() ran and the messenger rendered, with no page errors.
  • No non-ASCII bytes remain in build/browser, build/cjs, build/esm, build/embed or published/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

  • Reach unknown. New Relic shows no clear step at the release. Session starts are about 10-13% below last week since then, but they were also lower in windows before the release. Identifies are down about 25% in all windows, so that isn't explained by this bug.
  • CDN charset unchanged. The CDN still sends no charset. With ascii_only it no longer matters for this bundle, so I left it alone. published/_headers could add one later if wanted.

Rollout

Merging to master deploys to the CDN through Cloudflare Workers Builds, including latest. npm needs the 19.4.1 tag pushed after that. Neither has been done.

🤖 Generated with Claude Code

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>
@boehlerlukas
boehlerlukas merged commit 62c2d05 into master Nov 6, 2026
1 check passed
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.

1 participant