Skip to content

fix(stats): resolve SVG dimensions safely during animated chart export - #1479

Merged
tannerlinsley merged 1 commit into
mainfrom
seer/fix/stats-npm-animated-export-svg-dimensions
Nov 1, 2026
Merged

tannerlinsley merged 1 commit into
mainfrom
seer/fix/stats-npm-animated-export-svg-dimensions

Conversation

@sentry

@sentry sentry Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

During animated (GIF and WebM) chart export on /stats/npm, each frame is rendered off-screen into an unattached container element using @tanstack/charts/svg/resources. The root SVG is rendered with width="100%" and height="100%".

When getSvgDimensions attempted to read svg.width.baseVal.value (and height), Chromium-based browsers threw NotSupportedError: Failed to read the 'value' property from 'SVGLength': Could not resolve relative length. because relative percentage lengths cannot be resolved on elements that lack a layout viewport. The existing fallbacks (viewBox and bounding box) were never evaluated because the property access threw immediately.

Changes:

  • Extract SVG dimension resolution into src/components/npm-stats/svgDimensions.ts.
  • Skip attempting to resolve baseVal.value when unitType is SVG_LENGTHTYPE_PERCENTAGE (returning 0 to immediately engage the fallback chain).
  • Catch NotSupportedError when reading baseVal.value and return 0, ensuring the existing viewBox fallback is used without masking unexpected errors.
  • Add unit tests in tests/npm-svg-dimensions.test.ts covering percentage lengths, throwing accessors, absolute pixel lengths, and unexpected error re-throwing.

Fixes TANSTACK-COM-5DS

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@changeset-bot

changeset-bot Bot commented Nov 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 161f648

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 896e4d20-6e97-4eea-8d93-1a6dac0318bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 161f648 Commit Preview URL

Branch Preview URL
Nov 01 2026, 11:06 AM

@tannerlinsley
tannerlinsley merged commit 1ceb069 into main Nov 1, 2026
8 checks passed
@tannerlinsley
tannerlinsley deleted the seer/fix/stats-npm-animated-export-svg-dimensions branch November 1, 2026 11:19
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