Skip to content

fix: serve JavaScript assets with a stable MIME type - #6831

Open
LeoGrosjean wants to merge 2 commits into
reflex-dev:mainfrom
LeoGrosjean:fix/windows-js-mime
Open

fix: serve JavaScript assets with a stable MIME type#6831
LeoGrosjean wants to merge 2 commits into
reflex-dev:mainfrom
LeoGrosjean:fix/windows-js-mime

Conversation

@LeoGrosjean

@LeoGrosjean LeoGrosjean commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • serve .js and .mjs static assets as text/javascript rather than relying on host MIME mappings
  • cover identity and precompressed responses when the system reports .js as text/plain

Problem

On Windows, Python reads the .js content type from the registry. If it is registered as text/plain, production Reflex serves ES-module assets with that type, and browsers reject them before the frontend can hydrate.

Testing

  • uv run ruff check reflex/utils/precompressed_staticfiles.py tests/units/utils/test_precompressed_staticfiles.py
  • uv run pytest tests/units/utils/test_precompressed_staticfiles.py

Review in cubic

@LeoGrosjean
LeoGrosjean requested a review from a team as a code owner August 1, 2026 21:14
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR stabilizes the MIME type used for JavaScript static assets so host-specific MIME mappings cannot prevent frontend hydration.

  • Forces .js and .mjs identity and precompressed responses to use text/javascript.
  • Adds unit coverage for identity and gzip responses when the system maps JavaScript to text/plain.
  • Adds a bug-fix release note.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
reflex/utils/precompressed_staticfiles.py Computes media types from the original asset path and explicitly normalizes JavaScript modules to text/javascript.
tests/units/utils/test_precompressed_staticfiles.py Verifies stable JavaScript MIME handling for identity and gzip responses under an incorrect host MIME mapping.
news/6831.bugfix.md Documents the Windows frontend hydration fix.

Reviews (2): Last reviewed commit: "chore: add changelog fragment for JavaSc..." | Re-trigger Greptile

@codspeed-hq

codspeed-hq Bot commented Aug 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing LeoGrosjean:fix/windows-js-mime (0404cb7) with main (a08a061)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

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