Skip to content

Comments

fix: strip query strings before matching exclude patterns#10

Merged
NathanFlurry merged 2 commits intomainfrom
fix/hmr-query-string-exclude
Feb 10, 2026
Merged

fix: strip query strings before matching exclude patterns#10
NathanFlurry merged 2 commits intomainfrom
fix/hmr-query-string-exclude

Conversation

@NathanFlurry
Copy link
Member

Summary

  • Vite appends cache-busting query strings (e.g. ?t=1707350000) to module URLs during HMR
  • The exclude patterns use $ anchors expecting URLs to end with file extensions (e.g. /.*\.tsx?$/)
  • URLs like /frontend/App.tsx?t=123 fail to match because the string ends with the query parameter
  • This causes HMR requests to leak through to the app server, which returns 404 text/plain
  • The browser rejects the module due to wrong MIME type and the page goes blank

The fix strips query strings before testing against exclude patterns, so both the full URL and path-only portion are checked.

Test plan

  • Start a Vite dev server using vite-plugin-srvx with a React app
  • Make a code change to a .tsx file
  • Verify HMR applies the change without a blank screen or console errors
  • Verify curl -I /frontend/App.tsx?t=123 returns 200 text/javascript (not 404 text/plain)

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.
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 8, 2026

Open in StackBlitz

npm i https://pkg.pr.new/rivet-dev/vite-plugin-srvx@10

commit: 3c824f5

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@NathanFlurry NathanFlurry merged commit b48d772 into main Feb 10, 2026
4 checks passed
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