remix icon indicating copy to clipboard operation
remix copied to clipboard

[Bug]: Hot Reload not working with Cloudflare Pages

Open wallyfaye opened this issue 3 years ago • 9 comments
trafficstars

What version of Remix are you using?

^1.1.1

What version of Node are you using? Minimum supported version is 14.

v17.0.1

Steps to Reproduce

npx create-remix@latest
# choose Cloudflare Pages
cd [whatever you named the project]
npm run dev
  • Edit the file app/routes/index.jsx
  • Observe the File changed log in your console as well as the related logs
  • Observe that http://127.0.0.1:8788/ has not changed
  • Refresh the page
  • Observe that http://127.0.0.1:8788/ has not changed
  • Ctrl+C to stop the npm script
  • run npm run dev again
  • Observe that the edit to app/routes/index.jsx is now present
  • edit the file again
  • observe that the change are still not present

Expected Behavior

We'd expect the changes to be immediately apparent

Actual Behavior

The changes are not visible until the process has be stopped and restarted using the npm run dev command

wallyfaye avatar Dec 18 '21 19:12 wallyfaye

This is a known issue and is in Cloudflare's hands to get Wrangler@v2 to support additional watch directories: https://github.com/cloudflare/wrangler2/issues/49

jacob-ebey avatar Dec 18 '21 20:12 jacob-ebey

If you haven't seen it, checkout this comment where you can now install wangler@pages and hot reloading should work. It doesn't seem like other attached issues have been updated... but for now, installing the pages package enables hot reloading for me.

I believe the create-remix CLI has the wrangler package set at alpha... so just update it to pages and things should start working.

drewdecarme avatar Jan 03 '22 02:01 drewdecarme

@drewdecarme appreciate the tip! that worked for me as well

schpet avatar Jan 03 '22 03:01 schpet

Hot reload is not working on Architect Sandbox either. #1601 I mentioned this here.

dan-cooke avatar Feb 09 '22 19:02 dan-cooke

Not working on o remix 1.1.3 and 1.2.2 even with wrangler@pages.

and3rsonsousa avatar Feb 23 '22 22:02 and3rsonsousa

For me, the browser needs to refresh twice in order to see updates.

So each hot reload shows the second-most-recent update, not the one I just made.

This is pretty annoying for my workflow. :(

"@remix-run/cloudflare": "^1.5.1",
"@remix-run/cloudflare-pages": "1.5.1",
"@remix-run/dev": "^1.5.1",
"@remix-run/react": "1.5.1",
"wrangler": "^beta"

I started another project with Remix + Cloudflare Pages about 8 weeks ago and I remember noticing that one of the version upgrades I made caused this to start happening. I don't really know enough about what's going on to say if this might be an issue with wrangler also/instead.

Edit:

I have an app with the following versions where the live reload works:

"@remix-run/cloudflare-pages": "^1.1.3",
"@remix-run/dev": "^1.1.3",
"@remix-run/react": "^1.1.3",
"@remix-run/serve": "^1.1.3",
"wrangler": "^0.0.16"

tulup-conner avatar Jun 06 '22 23:06 tulup-conner

not working with cloudflare workers too.

image

lili21 avatar Nov 03 '22 03:11 lili21

Anyone making any progress on this or can point me in the right direction to make a fix? having the issue myself.

Edit:

Not sure if they have been updated in the last couple days but using the current versions from the create -> cloudflare pages script do work

"dependencies": { "@remix-run/cloudflare": "^1.9.0", "@remix-run/cloudflare-pages": "^1.9.0", "@remix-run/react": "^1.9.0", "cross-env": "^7.0.3", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { "@cloudflare/workers-types": "^3.18.0", "@remix-run/dev": "^1.9.0", "@remix-run/eslint-config": "^1.9.0", "@types/react": "^18.0.25", "@types/react-dom": "^18.0.8", "eslint": "^8.27.0", "npm-run-all": "^4.1.5", "typescript": "^4.8.4", "wrangler": "^2.2.1" },

acoreyj avatar Dec 29 '22 15:12 acoreyj

We've implemented a new platform-agnostic dev server in #5133 which will be available under the unstable_dev flag in the next minor release.

pcattori avatar Jan 24 '23 00:01 pcattori

@pcattori Can you help me make it work with cloudflare-pages? Here is the discussion.

kishanhitk avatar Feb 16 '23 10:02 kishanhitk

i’m trying to make the new dev server + HMR work with cloudflare-workers (using miniflare). i would love to help debug by testing any suggestions and combinations / permutations of configs to see if i can get it to work. my current issue is that i cannot get the websocket server to run, or at least not on any port that i can identify. i documented some of my attempts in this discussion.

acusti avatar Mar 03 '23 17:03 acusti

Obsoleted by #6133 .

You should now be able to use the -c/--command to run miniflare or any other local app server w/ the Remix dev server. Be sure to follow the instructions in the 1.16 release notes to set up the dev server correctly.

pcattori avatar May 01 '23 23:05 pcattori

You can give the unstable dev server a run on cf pages and cf workers with the following commands:

Pages

npx create-remix@latest --template https://github.com/remix-run/remix/tree/templates_v2_dev/templates/cloudflare-pages

Workers

npx create-remix@latest --template https://github.com/remix-run/remix/tree/templates_v2_dev/templates/cloudflare-workers

jacob-ebey avatar May 02 '23 01:05 jacob-ebey