Fix ENAMETOOLONG crash when CSS data URIs are processed by tsconfig alias plugin#17294
Open
astrobot-houston wants to merge 2 commits into
Open
Fix ENAMETOOLONG crash when CSS data URIs are processed by tsconfig alias plugin#17294astrobot-houston wants to merge 2 commits into
astrobot-houston wants to merge 2 commits into
Conversation
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
|
matthewp
approved these changes
Jul 4, 2026
|
Should there be another try-catch around |
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.
Changes
url('data:image/...')data URIs no longer crashastro buildwithENAMETOOLONGwhentsconfig.jsonhascompilerOptions.baseUrlset. Thevite-plugin-config-aliasCSS transform now skips anyurl()reference that starts withdata:, since data URIs are inline content and never valid file paths to resolve.cssUrlREmatching added to the CSS transform handler (commit4766f3716d). The baseUrl alias regex/^(?!\.*\/|\.*$|\w:)(.+)$/was designed to exclude Windows drive letters but\w:only matches a single character before the colon, sodata:(4 chars) slipped through and was passed tofs.statSync().Closes #17293
Testing
packages/astro/test/alias-css-url-data-uri.test.tswith a fixture that combinestsconfig.jsonbaseUrl: "."and a CSSurl()data URI — verifies the build completes without error and the data URI is preserved in output.Docs