hyperfiddle 2025-09-01

When I deploy a new version of the starter app (also my app), I get a Reactor failure in the client. Details in thread.

đź‘€ 1

Repro

Fix • Apply the linked diff • clj -X:build:prod build-client :optimize false :version '"3"' • Restart server: ◦ Ctrl-C ◦ clj -M:prod -m prod • Reload tab at localhost:8080 to load the new client entrypoint. Client is now running version 3. • Simulate a new version: clj -X:build:prod build-client :optimize false :version '"4"' • Restart server to simulate a deploy: ◦ Ctrl-C ◦ clj -M:prod -m prod • Look at localhost:8080. It should: ◦ fail to reconnect with the same error “Stale Electric client” ◦ print a message: “Electric server and Electric client version mismatches. Refreshing page to load new assets.” ◦ automatically perform a refresh and load version 4.

You can apply to same quick fix to your app’s entrypoint.

The current behavior (crash and blank page) is not an acceptable default. The auto-reload behavior should probably be the default. But it may be equally intrusive to users. Showing a js/alert dialog informing users a reload is necessary may be better. We’ll think about it. I encourage you to look at hyperfiddle.electric-client3/reload-when-stale.

@adham.rasoul can we capture/document this please?

👍 1

Thanks — I confirm that change works.

(I agree that a js/alert is probably a good idea.)

Dustin Getz (Hyperfiddle) 2025-09-24T12:26:21.689719Z

@ggaillard are you saying the starter app does NOT currently have reload-when-stale?

Dustin Getz (Hyperfiddle) 2025-09-24T12:27:09.357149Z

the action therefore is to fix the starter app? If end users wish to customize the behavior they can do so?

Exactly

👍 1

Fixed in latest starter app. Also https://gitlab.com/hyperfiddle/electric3-starter-app/-/commit/dea346bd3fb59c149b6c13570e1c0c09f5feaff1 (e.g. stale CSS after deployment).

👍 2

This is a cache busting issue. The problem is the client still runs the old version. Which is incompatible with the newly deployer server version. A page refresh should fetch the new .js artifact. Connected clients should gracefully disconnect on server deploy and issue a page refresh on the next reconnect attempt. Electric ships with a ring middleware handling exactly this case. IIRC it's called "wrap-reject-stale-clients". It should be part of the starter app prod setup. I'll check if it's missing or if there's a bug.

🙏 1

Did you get a chance to look at this?

Is this expected behaviour?

This is in Chrome, but I’m pretty sure I’ve seen it in non-Chromium browsers too (eg Safari). (EDIT: Confirmed with Safari.)

Seems to be the same with both uberjar and Docker.

…and I have to manually refresh the browser to get the app back.