remix: HMR not working in `cloudflare-pages` template

What version of Remix are you using?

1.16.1

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

  1. npx create-remix@latest --template https://github.com/remix-run/remix/tree/templates_v2_dev/templates/cloudflare-pages
  2. npm run dev
  3. change something in the /app/routes/_index.tsx file
  4. open console and see: console-error

Expected Behavior

HMR should work after changing the file

Actual Behavior

After changing the file, HMR does not work, and an error appears in the console, the changes can only be seen if you manually reload the page. Perhaps this is due to the race condition #6286

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 23 (14 by maintainers)

Most upvoted comments

It works great for me with Wrangler v3.

I am getting a strange error with it when I try to start the dev server:

@Jackardios I got this too after upgrading to v3. I had to update my wranger.toml to remove streams_enable_constructors from the compatibility_flags because above that error you mentioned I got this: The compatibility flag streams_enable_constructors became the default as of 2022-11-30

I had the same issue (HMR not working) with Cloudflare workers, remix 1.19.3, and wrangler 3.7.0. The thing that resolved it for me was updating my remix.config.js with:

  serverConditions: ['workerd', 'worker', 'browser'],

Following this template: https://github.com/remix-run/remix/blob/main/templates/cloudflare-workers/remix.config.js

If you can share a reproduction, I’d be happy to look at it!

On Sat, Jul 22, 2023 at 07:56 Aaron Adams @.***> wrote:

Thanks @defjosiah https://github.com/defjosiah. That’s the same combination I’m using without success.

It seems the problem is with watchPaths, if I remove this from our config then HMR works. I’ll have to file a separate issue when I get the chance.

— Reply to this email directly, view it on GitHub https://github.com/remix-run/remix/issues/6415#issuecomment-1646601186, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXLPHJ2AXO3WGC63YY7LGTXRPSYVANCNFSM6AAAAAAYF24CBI . You are receiving this because you were mentioned.Message ID: @.***>

@huw I am using wrangler v2. Did you manage to use version 3 with the remix? I am getting a strange error with it when I try to start the dev server: [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above. (but there is no additional information above)

@pcattori it looks like it really is due to a race condition. If you set timeout to logDevReady no error occurs:

// server.ts
import { logDevReady } from "@remix-run/cloudflare";
import { createPagesFunctionHandler } from "@remix-run/cloudflare-pages";
import * as build from "@remix-run/dev/server-build";

if (process.env.NODE_ENV === "development") {
  setTimeout(() => logDevReady(build), 200);
}

export const onRequest = createPagesFunctionHandler({
  build,
  getLoadContext: (context) => ({ env: context.env }),
  mode: process.env.NODE_ENV,
});