Repository navigation
fix(mcp-cloudflare): guard WebAssembly import in TerminalAnimation - #1345
Conversation
There was a problem hiding this comment.
Looks good at 3e76b52. The latest motivating event reaches asciinema-player 3.17.0's __wbg_load → WebAssembly.instantiate; the installed dependency starts that initialization during module evaluation. Guarding before the dynamic import prevents the actual failure without catching unrelated errors or changing supported-browser behavior. The evidence establishes an absent WebAssembly global, not the description's specific private-browsing explanation.
Verified the built client at http://localhost:5173 in Chromium with WebAssembly absent (--js-flags=--jitless): no player/chunk load and no page errors; the page and installation tabs remain usable. Removing only the compiled guard in a separate control reproduces ReferenceError: WebAssembly is not defined. With WebAssembly enabled, the player loads demo.cast and renders the terminal. This is a capability simulation, not an iOS Safari test. Used the static client build because the repo dev server requires an authenticated Cloudflare remote proxy.
The client build and all 430 Cloudflare tests pass locally. Current-head CI, including the required test gate, is successful. No code corrections needed.
…1346) The env-token-ignored hint claimed the user set a `SENTRY_AUTH_TOKEN` env var even when the token actually came from a `[auth] token` in `.sentryclirc` (the shim copies it into `SENTRY_AUTH_TOKEN` at boot). The shim now records the injecting `.sentryclirc` path and the hint names it instead, so the source is accurate. Scoped to the incorrect-source bug from #1345. The larger behavior proposal in the issue (trust org/host-embedded tokens, only fall back to the stored DB token when the other fails/can't be trusted) is a separate design change and isn't included here. ## Testing `pnpm exec vitest run test/lib/auth-hint.test.ts test/lib/sentryclirc.test.ts` (39 passed), plus `pnpm run typecheck` and `pnpm run lint` clean. Closes #1345 <!-- ## Plan Root cause: applySentryCliRcEnvShim in src/lib/sentryclirc.ts maps a .sentryclirc [auth] token into env.SENTRY_AUTH_TOKEN. Later, maybeWarnEnvTokenIgnored in src/lib/auth-hint.ts reports "Detected SENTRY_AUTH_TOKEN env var" using getActiveEnvVarName(), which cannot tell an rc-injected token from a real env var. The user sees a wrong source. Changes: - src/lib/sentryclirc.ts: add module-local rcInjectedTokenSource, set it to config.sources.token when the shim injects the token, expose getRcInjectedTokenSource(), and reset it in clearSentryCliRcCache(). - src/lib/auth-hint.ts: add describeIgnoredTokenSource() naming the .sentryclirc file when rc-injected, else the env-var name. - tests for both the shim provenance and the hint wording. Out of scope: token trust/precedence changes (issue items 1 and 2). --> --------- Co-authored-by: jared-outpost[bot] <jared-outpost[bot]@users.noreply.github.com>
…etsentry#1346) The env-token-ignored hint claimed the user set a `SENTRY_AUTH_TOKEN` env var even when the token actually came from a `[auth] token` in `.sentryclirc` (the shim copies it into `SENTRY_AUTH_TOKEN` at boot). The shim now records the injecting `.sentryclirc` path and the hint names it instead, so the source is accurate. Scoped to the incorrect-source bug from getsentry#1345. The larger behavior proposal in the issue (trust org/host-embedded tokens, only fall back to the stored DB token when the other fails/can't be trusted) is a separate design change and isn't included here. ## Testing `pnpm exec vitest run test/lib/auth-hint.test.ts test/lib/sentryclirc.test.ts` (39 passed), plus `pnpm run typecheck` and `pnpm run lint` clean. Closes getsentry#1345 <!-- ## Plan Root cause: applySentryCliRcEnvShim in src/lib/sentryclirc.ts maps a .sentryclirc [auth] token into env.SENTRY_AUTH_TOKEN. Later, maybeWarnEnvTokenIgnored in src/lib/auth-hint.ts reports "Detected SENTRY_AUTH_TOKEN env var" using getActiveEnvVarName(), which cannot tell an rc-injected token from a real env var. The user sees a wrong source. Changes: - src/lib/sentryclirc.ts: add module-local rcInjectedTokenSource, set it to config.sources.token when the shim injects the token, expose getRcInjectedTokenSource(), and reset it in clearSentryCliRcCache(). - src/lib/auth-hint.ts: add describeIgnoredTokenSource() naming the .sentryclirc file when rc-injected, else the env-var name. - tests for both the shim provenance and the hint wording. Out of scope: token trust/precedence changes (issue items 1 and 2). --> --------- Co-authored-by: jared-outpost[bot] <jared-outpost[bot]@users.noreply.github.com>
This PR addresses a
ReferenceError: Can't find variable: WebAssemblythat occurs in environments where WebAssembly is not available, such as iOS Safari in private browsing mode.The root cause was the unconditional dynamic import of
asciinema-playerinpackages/mcp-cloudflare/src/client/components/animation/TerminalAnimation.tsx. Theasciinema-playerpackage includes a Rust/WASM bundle that attempts to access theWebAssemblyglobal upon import, leading to a crash if it's undefined.To fix this, a guard
if (typeof WebAssembly === "undefined") return;has been added immediately before theawait import("asciinema-player")call. This ensures that theasciinema-playeris only loaded if WebAssembly is supported, allowing the component to gracefully degrade (the animation will not play) in unsupported environments without crashing the application.Fixes MCP-SERVER-FZA
@sentry <feedback>: Autofix iterates on these changes@sentry stop iterating: Autofix stops iterating on this runThis PR was automatically generated by Sentry. You can adjust this setting at any time.