Skip to content

Fix ENAMETOOLONG crash when CSS data URIs are processed by tsconfig alias plugin#17294

Open
astrobot-houston wants to merge 2 commits into
mainfrom
triagebot/fix-17293
Open

Fix ENAMETOOLONG crash when CSS data URIs are processed by tsconfig alias plugin#17294
astrobot-houston wants to merge 2 commits into
mainfrom
triagebot/fix-17293

Conversation

@astrobot-houston

Copy link
Copy Markdown
Contributor

Changes

  • CSS url('data:image/...') data URIs no longer crash astro build with ENAMETOOLONG when tsconfig.json has compilerOptions.baseUrl set. The vite-plugin-config-alias CSS transform now skips any url() reference that starts with data:, since data URIs are inline content and never valid file paths to resolve.
  • The regression was introduced in v7 by the cssUrlRE matching added to the CSS transform handler (commit 4766f3716d). The baseUrl alias regex /^(?!\.*\/|\.*$|\w:)(.+)$/ was designed to exclude Windows drive letters but \w: only matches a single character before the colon, so data: (4 chars) slipped through and was passed to fs.statSync().

Closes #17293

Testing

  • Adds packages/astro/test/alias-css-url-data-uri.test.ts with a fixture that combines tsconfig.json baseUrl: "." and a CSS url() data URI — verifies the build completes without error and the data URI is preserved in output.

Docs

  • No docs update needed; this restores previously working behavior from v6.

Data URIs like url('data:image/svg+xml;base64,...') were incorrectly
matched by the baseUrl alias regex and passed to fs.statSync(), which
throws ENAMETOOLONG when the base64 string exceeds the OS filename
length limit (255 bytes).

Add an early return in replaceAliases() to skip data: URIs since they
are inline content, not file paths to resolve.

Fixes #17293
Data URIs like url('data:image/svg+xml;base64,...') were incorrectly
matched by the baseUrl alias regex and passed to fs.statSync(), which
throws ENAMETOOLONG when the base64 string exceeds the OS filename
length limit (255 bytes).

Add an early return in replaceAliases() to skip data: URIs since they
are inline content, not file paths to resolve.

Fixes #17293
@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ee57c57

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.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Jul 3, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 3, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing triagebot/fix-17293 (ee57c57) with main (f94280d)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (6929e40) during the generation of this report, so f94280d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@OverflowCat

Copy link
Copy Markdown

Should there be another try-catch around fs.statSync?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix verified Reporter confirmed the triage bot fix works pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENAMETOOLONG crash when CSS contains url('data:image/...') with tsconfig.baseUrl set

3 participants