From 3655942fa4355610c148814540d407b204910d4f Mon Sep 17 00:00:00 2001 From: Clive F Date: Wed, 10 Jun 2026 11:01:12 +0100 Subject: [PATCH] fix: reload stale clients on any older app version, not just major (#21011) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Context The GraphQL error handler emits an `APP_VERSION_MISMATCH` error (surfaced on the client as a "your app version is out of date, please refresh" prompt) when a client's app version is behind the server's. Today that comparison only fires when the **major** version differs: ```ts const frontEndMajor = semver.parse(frontEndAppVersion)?.major; const backendMajor = semver.parse(backendAppVersion)?.major; if (isDefined(frontEndMajor) && isDefined(backendMajor) && frontEndMajor < backendMajor) { ... } ``` Twenty ships schema changes in minor and patch releases too. A tab left open across a minor/patch deploy keeps sending GraphQL documents built against the previous schema. If a field was removed or renamed, those operations fail with opaque field-level errors and the user never gets the refresh prompt — a hard reload is the only recovery. ## What this does - **Server:** fires the mismatch whenever the client version is strictly older than the server (`semver.lt`), regardless of which version component changed. - **Client:** `onAppVersionMismatch` now reloads the page once (in addition to the existing snackbar) to pull the current `index.html` and hashed assets, guarded by a short `sessionStorage` window so a still-stale reload can't cause a refresh loop. ## Notes - No behavior change for clients on the same or newer version. - Relies on the existing `x-app-version` header and `APP_VERSION` config that already drive this check. --------- Co-authored-by: Charles Bochet --- .../graphql/hooks/use-graphql-error-handler.hook.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/twenty-server/src/engine/core-modules/graphql/hooks/use-graphql-error-handler.hook.ts b/packages/twenty-server/src/engine/core-modules/graphql/hooks/use-graphql-error-handler.hook.ts index f068be4cd3..fce6f8972e 100644 --- a/packages/twenty-server/src/engine/core-modules/graphql/hooks/use-graphql-error-handler.hook.ts +++ b/packages/twenty-server/src/engine/core-modules/graphql/hooks/use-graphql-error-handler.hook.ts @@ -304,14 +304,7 @@ export const useGraphQLErrorHandlerHook = < return; } - const frontEndMajor = semver.parse(frontEndAppVersion)?.major; - const backendMajor = semver.parse(backendAppVersion)?.major; - - if ( - isDefined(frontEndMajor) && - isDefined(backendMajor) && - frontEndMajor < backendMajor - ) { + if (semver.lt(frontEndAppVersion, backendAppVersion)) { void options.metricsService.incrementCounterForEvent({ key: MetricsKeys.AppVersionMismatch, });