Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: React Dev Tools injects its own js code (installHook.js) and then tries to download the source map if its own code #32339

Open
staenker opened this issue Feb 8, 2025 · 3 comments
Assignees
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@staenker
Copy link

staenker commented Feb 8, 2025

React Dev Tools injects its own js code (installHook.js) and then tries to download the source map of its own code. Since my app does not know about installHook.js it can not generate the source map. So far, no harm done. But then, I get that huge warning in my console. And I google... And I chatGPT, dive into the deep realms of generating source maps, ...and after wasting an hour... find out by digging into the source code of the dev tools, that someone was too lazy to filter out your own files. The internet is full of this problem. It is time to fix it.

React version: 19.0.0

Steps To Reproduce

  1. Create a react app
  2. install react developer tools
  3. execute npm run dev
  4. open the console of the browser
  5. be annoyed by a warning, that the sourceMap of installHook.js cannot be found or is invalid

Link to code example: I tried using CodeSandbox, CodeSandbox itself is filling my console with warnings... Just execute a good old google query: https://www.google.com/search?q=installhook.js.map

Workaround

Serve your own installHook.js.map file. I put one in the public directory of my react app. Contents:

{
  "version": 3,
  "file": "installHook.js",
  "sources": ["installHook.js"],
  "sourcesContent": [""],
  "mappings": ""
}

The current behavior

Image

The expected behavior

I don't see a warning.

@staenker staenker added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Feb 8, 2025
@TommeZ
Copy link

TommeZ commented Feb 8, 2025

Getting a similar error in my Firefox console when using the React Dev Tools add on

Image

@hoxyq hoxyq self-assigned this Feb 10, 2025
@hoxyq
Copy link
Contributor

hoxyq commented Feb 10, 2025

I am pretty sure it is Firefox-only issue and it is because it can't handle relative source map urls for React DevTools' scripts.

From React DevTools perspective, I believe we are shipping correct source maps and I do believe this is a limitation on Firefox side.

Would appreciate anyone spending some time to do a research if we can somehow fix this for Firefox extension, but we certainly need to ship source map for this script to get it ignore listed. I am happy to share more context on why we ship source map for our browser extension, if needed.

@thebrownfox
Copy link

This causes rerendering of astro pages as well 😅

withastro/astro#13285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

4 participants