hyperfiddle

2025-09-01T18:44:03.135349Z

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
Geoffrey Gaillard 2025-09-24T08:23:44.303979Z

Repro

Geoffrey Gaillard 2025-09-24T08:30:52.137969Z

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.

Geoffrey Gaillard 2025-09-24T08:34:49.974549Z

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

Geoffrey Gaillard 2025-09-24T08:36:40.657679Z

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.

Geoffrey Gaillard 2025-09-24T08:37:14.044649Z

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

👍 1
adham 2025-09-24T08:43:23.326769Z

Of course

1
2025-09-24T12:14:53.226339Z

Thanks — I confirm that change works.

2025-09-24T12:15:27.842219Z

(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?

Geoffrey Gaillard 2025-09-24T12:47:58.620719Z

Exactly

👍 1
Geoffrey Gaillard 2025-11-13T12:21:28.827439Z

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

👍 2
Geoffrey Gaillard 2025-09-02T18:23:37.687819Z

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
2025-09-23T23:41:39.018129Z

Did you get a chance to look at this?

2025-09-01T18:44:47.333019Z

2025-09-01T18:45:22.118929Z

Is this expected behaviour?

2025-09-01T18:48:15.111419Z

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

2025-09-01T18:56:19.418999Z

Seems to be the same with both uberjar and Docker.

2025-09-01T19:16:02.282499Z

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