fix(editor): polyfill structuredClone for legacy browsers (Sentry MONOREPO-EDITOR-FB)#524
Open
anton-pascal wants to merge 1 commit into
Open
fix(editor): polyfill structuredClone for legacy browsers (Sentry MONOREPO-EDITOR-FB)#524anton-pascal wants to merge 1 commit into
anton-pascal wants to merge 1 commit into
Conversation
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.
Summary
structuredClonepolyfill for browsers that do not provide the native APIinstrumentation-client.tsbefore the editor's client modules are evaluated@ungap/structured-cloneSentry issue
Sentry issue MONOREPO-EDITOR-FB shows the public viewer failing entirely on legacy Android browsers (including Honor Browser 9.8.0 / Chromium <98) with
ReferenceError: structuredClone is not defined.@pascal-app/lingo@0.2.0callsstructuredCloneduring module initialization throughregisterKind. The package is imported bypackages/editor/src/lib/measurement-parser.ts, so app-level component guards run too late. Installing the global fallback from the client instrumentation entry ensures it exists before the editor/lingo module graph is evaluated.Validation
bun install --frozen-lockfile✅Generated from the nightly Sentry triage cron.
Note
Low Risk
Small, guarded client bootstrap change with a well-known polyfill; native browsers are untouched and scope is limited to the editor app.
Overview
Fixes hard crashes on legacy browsers (e.g. older Android / Chromium <98) where
structuredCloneis missing and the editor fails during module load (Sentry MONOREPO-EDITOR-FB).The editor app now depends on
@ungap/structured-cloneand installs a guarded global fallback inlib/polyfills/structured-clone.ts(only whenglobalThis.structuredCloneis not a function). That polyfill is pulled in frominstrumentation-client.tsso it runs before the rest of the client bundle—important because dependencies such as@pascal-app/lingocan callstructuredCloneat import time.A local
ungap-structured-clone.d.tstypes the polyfill package for TypeScript.Reviewed by Cursor Bugbot for commit e380b05. Bugbot is set up for automated code reviews on this repo. Configure here.