fix: strip query strings before matching exclude patterns#10
Merged
NathanFlurry merged 2 commits intomainfrom Feb 10, 2026
Merged
fix: strip query strings before matching exclude patterns#10NathanFlurry merged 2 commits intomainfrom
NathanFlurry merged 2 commits intomainfrom
Conversation
Vite appends cache-busting query strings (e.g. ?t=1707350000) to module URLs during HMR. The exclude patterns use $ anchors that expect the URL to end with the file extension (e.g. /.*\.tsx?$/), which fails to match URLs with query parameters. This causes HMR module requests to leak through to the app server, which returns 404 with text/plain MIME type. The browser rejects the module and the page goes blank. Fix by also testing exclude patterns against the URL path (without query string), so /frontend/App.tsx?t=123 correctly matches /.*\.tsx?$/ via the path portion /frontend/App.tsx.
commit: |
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
?t=1707350000) to module URLs during HMR$anchors expecting URLs to end with file extensions (e.g./.*\.tsx?$/)/frontend/App.tsx?t=123fail to match because the string ends with the query parameter404 text/plainThe fix strips query strings before testing against exclude patterns, so both the full URL and path-only portion are checked.
Test plan
.tsxfilecurl -I /frontend/App.tsx?t=123returns200 text/javascript(not404 text/plain)