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

Hot Reload Fails, DOM adds an additional iframe containing entire contents of the html DOM element #11880

Closed
jake-engel opened this issue Jan 4, 2022 · 32 comments

Comments

@jake-engel
Copy link

Describe the bug

Everytime I save my code and hot reload happens, I am then unable to interact with the application (every component becomes unclickable). Upon further inspection of the DOM, I noticed that there was an iframe added within the document body which contains the entire HTML root, as well some various JS (see image below). If I remove this added iframe I am then able to interact with the application again (and hot reloads will work as normal following the removal).

There are no console errors, or warnings corresponding to this issue

Did you try recovering your dependencies?

Yes, I have tried removing all my dependency files multiple times, but still run into this issue. I am running yarn version 1.22.15 and this is within a project using yarn workspaces.

Which terms did you search for in User Guide?

Hot reload, iframe

Environment

  current version of create-react-app: 4.0.3
  running from /Users/-----/.config/yarn/global/node_modules/create-react-app

  System:
    OS: macOS 12.0.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 14.18.2 - ~/.nvm/versions/node/v14.18.2/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.2/bin/npm
  Browsers:
    Chrome: 96.0.4664.110
    Edge: Not Found
    Firefox: Not Found
    Safari: 15.1
  npmPackages:
    react:  17.0.2 (16.14.0)
    react-dom:  17.0.2 (16.14.0)
    react-scripts:  4.0.3 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. Run yarn start and wait for application to load
  2. Update the code on any component and hit 'save'
  3. Try to interact with the application after hitting save

Expected behavior

Hot reload should work as expected and no iframe should be added, I should be able to interact with the application immediately

Actual behavior

Application becomes non-interactive, iframe is added to DOM

image

@kirannambiar12
Copy link

kirannambiar12 commented Jan 5, 2022

I recently had this issue aswell.
I did couple of things to make it work. You can try these aswell.

  • Change the react-script version to 4.0.3 inside package.json.
  • Add this to package.json below the dependencies
    "resolutions": { "react-error-overlay": "6.0.9" },
  • Install react-error-overlay v6.0.9 inside your devDependencies.
  • Remove your node_modules and package-lock.json.
  • Do npm install and check that works.

Note: After doing the above steps i had to run npm install react-error-overlay@6.0.9 again to fix this issue.

Hope this helps!!

@jake-engel
Copy link
Author

Worked for me! Thanks a bunch

@therealnagaka
Copy link

This worked for me as well. The last note step is finally what did it. Thanks

@flaviodelgrosso
Copy link

flaviodelgrosso commented Jan 7, 2022

It's working for me, but I need to reinstall react-error-overlay again... It's really boring

@quisido
Copy link

quisido commented Jan 7, 2022

If you are using Yarn 2, Yarn 3, or Yarn berry, you need to manually patch your yarn.lock file, since Yarn 2+ doesn't obey the resolutions property of package.json. Instructions can be found here.

@talhabinkhalil
Copy link

I recently had this issue aswell. I did couple of things to make it work. You can try these aswell.

  • Change the react-script version to 4.0.3 inside package.json.
  • Add this to package.json below the dependencies
    "resolutions": { "react-error-overlay": "6.0.9" },
  • Install react-error-overlay v6.0.9 inside your devDependencies.
  • Remove your node_modules and package-lock.json.
  • Do npm install and check that works.

Note: After doing the above steps i had to run npm install react-error-overlay@6.0.9 again to fix this issue.

Hope this helps!!

Worked for me , thanks a bunch.

@rich-97
Copy link

rich-97 commented Jan 25, 2022

Also worked for me!

@abazunts
Copy link

@kirannambiar12 Also worked for me!

@ssthil
Copy link

ssthil commented Feb 17, 2022

Didn't work the below steps. Still there is iframe inside the dom.

I recently had this issue aswell.
I did couple of things to make it work. You can try these aswell.

Change the react-script version to 4.0.3 inside package.json.
Add this to package.json below the dependencies
"resolutions": { "react-error-overlay": "6.0.9" },
Install react-error-overlay v6.0.9 inside your devDependencies.
Remove your node_modules and package-lock.json.
Do npm install and check that works.
Note: After doing the above steps i had to run npm install react-error-overlay@6.0.9 again to fix this issue.

Hope this helps!!

image

@EvaGarzonBeltran
Copy link

The solution of install react-error-overlay didn't work for me and neither did the update to version 5 of react-scripts (the application doesn't start correctly). The iframe keeps showing up every time I make a code change.

image

@aldipee
Copy link

aldipee commented Feb 21, 2022

The solution of install react-error-overlay didn't work for me and neither did the update to version 5 of react-scripts (the application doesn't start correctly). The iframe keeps showing up every time I make a code change.

image

have you been able to solve this? I have exact problem

@EvaGarzonBeltran
Copy link

The solution of install react-error-overlay didn't work for me and neither did the update to version 5 of react-scripts (the application doesn't start correctly). The iframe keeps showing up every time I make a code change.
image

have you been able to solve this? I have exact problem

Not yet :(

@atulbhatt-system32
Copy link

atulbhatt-system32 commented Mar 1, 2022

I recently had this issue aswell. I did couple of things to make it work. You can try these aswell.

  • Change the react-script version to 4.0.3 inside package.json.
  • Add this to package.json below the dependencies
    "resolutions": { "react-error-overlay": "6.0.9" },
  • Install react-error-overlay v6.0.9 inside your devDependencies.
  • Remove your node_modules and package-lock.json.
  • Do npm install and check that works.

Note: After doing the above steps i had to run npm install react-error-overlay@6.0.9 again to fix this issue.

Hope this helps!!

This worked for me as well as I tried to resolve the same issue in my 3 colleagues system.
For me I followed all the steps.
But then I tried the same in my colleagues system I just added react-error-overlay in the package.json and did a npm install react-error-overlay@6.0.9 and finally all left was npm start.
And my friends, it worked.

@leonnleite
Copy link

leonnleite commented Mar 7, 2022

The solution of install react-error-overlay didn't work for me and neither did the update to version 5 of react-scripts (the application doesn't start correctly). The iframe keeps showing up every time I make a code change.
image

have you been able to solve this? I have exact problem

try this:

package.json

  "eslintConfig": {

    "env": {
      "browser": true,
      "node": true
    }
  },

@kirannambiar12
Copy link

@EvaGarzonBeltran @aldipee If nothing works out, I guess the one thing you can do is override the css and call it out as display none. But am not sure if this is the right thing to do.

@Nurpeyis
Copy link

Works for me as well as

@joneldiablo
Copy link

not working for me =(

@VLeads
Copy link

VLeads commented Mar 29, 2022

I recently had this issue aswell. I did couple of things to make it work. You can try these aswell.

  • Change the react-script version to 4.0.3 inside package.json.
  • Add this to package.json below the dependencies
    "resolutions": { "react-error-overlay": "6.0.9" },
  • Install react-error-overlay v6.0.9 inside your devDependencies.
  • Remove your node_modules and package-lock.json.
  • Do npm install and check that works.

Note: After doing the above steps i had to run npm install react-error-overlay@6.0.9 again to fix this issue.

Hope this helps!!

For 2-3 days this solution worked. But now it is not working. I even didn't installed any new package !!

@damian66
Copy link

damian66 commented Apr 2, 2022

I can confirm that it worked for me. I added the react-error-overlay package both to resolutions and devDependencies and had to reinstall packages.

@nicco-b
Copy link

nicco-b commented Apr 8, 2022

I recently had this issue aswell. I did couple of things to make it work. You can try these aswell.

  • Change the react-script version to 4.0.3 inside package.json.
  • Add this to package.json below the dependencies
    "resolutions": { "react-error-overlay": "6.0.9" },
  • Install react-error-overlay v6.0.9 inside your devDependencies.
  • Remove your node_modules and package-lock.json.
  • Do npm install and check that works.

Note: After doing the above steps i had to run npm install react-error-overlay@6.0.9 again to fix this issue.

Hope this helps!!

this does not work for me

@lcundiff
Copy link

@EvaGarzonBeltran and whoever else is having "process not defined error". If the steps outlined previously did not work for you (as it didn't work for me), and you are using NPM, then you need to use "overrides" instead of "resolutions" within your package.json. Also, my npm version was below 8.3 and therefore the "overrides" field was not being read. So you'll need to upgrade your npm to at least 8.3.

Then go ahead and follow the steps again outlined earlier in this thread (restart your docker container as well if applicable). I was able to figure this out from following this stackoverflow question.

If this still doesn't fix it and you've completely reinstalled all your modules and package lock, then I would suggest upgrading to react scripts 5 since that also seems to solve the issue.

@draco-malfoy
Copy link

For them who did not got this fixed with @kirannambiar12 solution, make sure the "resolutions" in package.json did it's job.

  1. Open package-lock.json and search for react-error-overlay and check if any of the matches have version other than "6.0.9". If there are any, the "resolutions" section did not work.
  2. Add a script in scripts section, "preinstall": "npx npm-force-resolutions"
  3. Do npm install

Now do step 1 again. This time all matches for react-error-overlay should have version "6.0.9". If they do, the fast refresh should work as expected.

@mknayan
Copy link

mknayan commented Jun 6, 2022

Please check first if there are any errors on importing modules or images. You may find it on console. After fixing that, hopefully it will fixed.

I found fixed on me.

@EvaGarzonBeltran
Copy link

At the end I was able to fix it by updating react-script. The error was in another library (ramdonstring) that was incompatible with the new version and made it impossible to start the app.

@scott-cornwell
Copy link

I tried all of these and it didn't work, but then I tried installing with yarn and that worked. npm doesn't support resolutions so the instructions to npm install I believe were a mistake, they meant to run yarn

@kamaladenalhomsi
Copy link

Adding react-error-overlay to devDependencies fixed it for me.

@LukeSamkharadze
Copy link

@jake-engel this issue shouldn't have been closed. This has to be fixed internally and not by some workarounds

@kg-currenxie
Copy link

I get this error when using responsive mode in Chrome
Screenshot 2022-07-14 at 21 02 23

Non-responsive works fine

@taofeek-ob
Copy link

Hi, for anyone still encountering the issue, updating react-scripts to the latest version, 5.0.1, as of now, fixed it for me.

  1. edited package.json:
    "react": "^17.0.1", "react-dom": "^17.0.1", "react-scripts": "5.0.1", "
  2. npm i

KayBeSee added a commit to Lily-Technologies/lily-wallet that referenced this issue Nov 1, 2022
iframe was being injected randomly b/c of react-scripts

see facebook/create-react-app#11880
ChangHyun-ssvt added a commit to s2vt/blockchain-explorer that referenced this issue Nov 8, 2022
Installed react-error-overlay 6.0.9 version
Reference: facebook/create-react-app#11880 (comment)
ChangHyun-ssvt added a commit to s2vt/blockchain-explorer that referenced this issue Nov 10, 2022
Installed react-error-overlay 6.0.9 version
Reference: facebook/create-react-app#11880 (comment)
barneyb added a commit to folded-ear/gobrennas-client that referenced this issue Nov 19, 2022
Since early last year, when CRA does a hot reload, its error overlay
drops an iframe over the entire document, forcing a manual reload. The
kludge of forcing an old version of the overlay seems to make it less
stupid (facebook/create-react-app#11880).

Switch to using CRA's eslint stuff, which was sorta equivalent-ish,
after adding our existing config to package.json. Still required a
bunch of no-op twiddles to get clean again, as well as disabling
linting for LoadObject and friends. They're vendored, Flow (not JS),
and on their way out.

Next, upgrade react-showdown, as the version we were using doesn't
work with Webpack 5, which react-scripts switched to (from 4).

Finally, MaterialUI got an unrequested update, which deprecated the
theme builder function. That's spiffed up. I didn't go digging as to
where/why it changed, or if there are other things. MUI seems to be
pretty good with semver, which is a refreshing change.

Some of the above glergage would be simplified with Yarn's PnP, as it
offers more control over the transitive stuff, but part of it is due to
CRA itself. And Node itself is at the root of the blame tree.
@devChrisho
Copy link

Didn't work the below steps. Still there is iframe inside the dom.

I recently had this issue aswell.
I did couple of things to make it work. You can try these aswell.

Change the react-script version to 4.0.3 inside package.json.
Add this to package.json below the dependencies
"resolutions": { "react-error-overlay": "6.0.9" },
Install react-error-overlay v6.0.9 inside your devDependencies.
Remove your node_modules and package-lock.json.
Do npm install and check that works.
Note: After doing the above steps i had to run npm install react-error-overlay@6.0.9 again to fix this issue.

Hope this helps!!
image

same. didn't work for me.
react-scripts 4.0.3
react-error-overlay 6.0.9

@mwsoofy
Copy link

mwsoofy commented Jul 16, 2023

  • "resolutions": { "react-error-overlay": "6.0.9" }

Works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests