create-react-app: Hot module reloading with proxy not working in Firefox but works in Chrome
Hi,
When developing using create-react-app
in Firefox 66.0.1, hot module reloading isn’t working, and I get this error in console when using npm run start
:
The connection to ws://localhost:3000/sockjs-node/800/q2e1i5qh/websocket was interrupted while the page was loading. websocket.js:7
This doesn’t happen in Chrome, and HMR works there as expected. I didn’t have problems in the past with Firefox, I’m not sure if it’s triggered by a Firefox update, or new versions of react-scripts. It may even be specific to my app.
I’m using react-scripts
versions 2.1.8
Does anyone know what would cause this, and how I could get HMR working again? I’m not really sure where to look.
Thanks
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 25
- Comments: 29 (5 by maintainers)
Commits related to this issue
- Update cra fork (#2) * Add question issue template (#7423) * Add question issue template * Fix bug report template formatting * Fix bug report template formatting * Add labels to pull req... — committed to WPMedia/create-react-app by deleted user 4 years ago
- Feature/customized webpack plugin integration (#2) * Fix CI issue on windows (#7385) * Attempt at fixing CI issue on windows * Try to debug why verdaccio isn't in the ps output * Just remove... — committed to ArbaazDossani/create-react-app by ArbaazDossani 4 years ago
Don’t close it stale bot! 😇
As a temporary workaround, using the manual proxy config instead of using the proxy entry in
package.json
worked for me.@andygock this is happening because you did close your open WebSocket. Try closing them
socket.close();
and retry.@Developerayo Where and how should I do this in a create-react-app project? I’m not using any WebSocket in my app itself, so I’m guessing the sockets are part of the HMR implementation.
There is an entry in the Mozilla issue tracker: https://bugzilla.mozilla.org/show_bug.cgi?id=1536843
Yeah on closer inspection it might not be related to the redirect. Sometimes it works and sometimes it doesn’t but I can’t seem to find a pattern to when it works.
Just tested this and can confirm this release has no issues.
Bumping to keep the issue from closing. Still using the manual proxy workaround.
Hot reloading functionality is always here https://github.com/facebook/create-react-app/blob/2add1288358f5d8ed6c162af32530255087153ce/packages/react-scripts/config/webpackDevServer.config.js#L63-L68 this endpoint already used by webpackHotDevClient https://github.com/facebook/create-react-app/blob/2add1288358f5d8ed6c162af32530255087153ce/packages/react-dev-utils/webpackHotDevClient.js#L66-L67 and it’s not a part of user defined functionality. What is the reason for hiding it behind proxy?
For example, it may be excluded (before accept header analyzing) by changing mayProxy method to
@mrmckeb @iansu , what do you think?
Following up from that bug (which was just resolved as invalid, because it seems like a bug in sockjs-client:
So possibly a down-stream sockjs-client issue? I’ll file a bug over there.
I’m having the same issue. Everything works fine in Chrome but in Firefox:
The connection to ws://localhost:3000/sockjs-node/698/osuont4q/websocket was interrupted while the page was loading. websocket.js:7
Clean create-react-app works fine. ~Could there be something wrong in the upgrade process?~
Update: I’m using Found for routing. In my app I do a redirect from “/”. When I remove this redirect the dev server does not disconnect. But only if I navigate to “/”. Any other route still has the same error.