@xh/hoist 67.0.0-SNAPSHOT.1725133204871 → 67.0.0-SNAPSHOT.1725151485260

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -37,6 +37,8 @@
37
37
 
38
38
  * Fixed Admin Console bug where a role with a dot in its name could not be deleted.
39
39
  * Fixed inline `SelectEditor` to ensure new value is flushed before grid editing stops.
40
+ * `WebSocketService` now attempts to establish a new connection when app's server instance changes.
41
+
40
42
 
41
43
  ### ✨ Styles
42
44
 
@@ -71,12 +71,18 @@ export class ClusterTabModel extends HoistModel {
71
71
  constructor() {
72
72
  super();
73
73
 
74
- this.addReaction({
75
- track: () => this.instanceName,
76
- run: instName => {
77
- if (instName) this.tabModel.refreshContextModel.refreshAsync();
74
+ this.addReaction(
75
+ {
76
+ track: () => this.instanceName,
77
+ run: instName => {
78
+ if (instName) this.tabModel.refreshContextModel.refreshAsync();
79
+ }
80
+ },
81
+ {
82
+ track: () => XH.environmentService.serverInstance,
83
+ run: () => this.gridModel.agApi.refreshCells({force: true})
78
84
  }
79
- });
85
+ );
80
86
  }
81
87
 
82
88
  private createGridModel() {
@@ -86,7 +92,6 @@ export class ClusterTabModel extends HoistModel {
86
92
  fields: [
87
93
  {name: 'name', type: 'string'},
88
94
  {name: 'isPrimary', type: 'bool'},
89
- {name: 'isLocal', type: 'bool'},
90
95
  {name: 'isReady', type: 'bool'},
91
96
  {name: 'wsConnections', type: 'int'},
92
97
  {name: 'startupTime', type: 'date'},
@@ -173,7 +178,7 @@ export class ClusterTabModel extends HoistModel {
173
178
  formatInstance(instance: PlainObject): ReactNode {
174
179
  const content = [instance.name];
175
180
  if (instance.isPrimary) content.push(badge({item: 'primary', intent: 'primary'}));
176
- if (instance.isLocal) content.push(badge('local'));
181
+ if (instance.name === XH.environmentService.serverInstance) content.push(badge('local'));
177
182
  return hbox(content);
178
183
  }
179
184
 
@@ -64,6 +64,7 @@ export declare class WebSocketService extends HoistService {
64
64
  connect(): void;
65
65
  disconnect(): void;
66
66
  heartbeatOrReconnect(): void;
67
+ private onServerInstanceChange;
67
68
  shutdown(): void;
68
69
  onOpen(ev: any): void;
69
70
  onClose(ev: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "67.0.0-SNAPSHOT.1725133204871",
3
+ "version": "67.0.0-SNAPSHOT.1725151485260",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",
@@ -71,7 +71,8 @@ export class WebSocketService extends HoistService {
71
71
 
72
72
  override async initAsync() {
73
73
  if (!this.enabled) return;
74
- if (XH.environmentService.get('webSocketsEnabled') === false) {
74
+ const {environmentService} = XH;
75
+ if (environmentService.get('webSocketsEnabled') === false) {
75
76
  this.logError(
76
77
  `WebSockets enabled on this client app but disabled on server. Adjust your server-side config.`
77
78
  );
@@ -81,6 +82,11 @@ export class WebSocketService extends HoistService {
81
82
 
82
83
  this.connect();
83
84
 
85
+ this.addReaction({
86
+ track: () => environmentService.serverInstance,
87
+ run: () => this.onServerInstanceChange()
88
+ });
89
+
84
90
  this._timer = Timer.create({
85
91
  runFn: () => this.heartbeatOrReconnect(),
86
92
  interval: 10 * SECONDS,
@@ -175,6 +181,12 @@ export class WebSocketService extends HoistService {
175
181
  }
176
182
  }
177
183
 
184
+ private onServerInstanceChange() {
185
+ this.logWarn('Server instance changed - attempting to connect to new instance.');
186
+ this.disconnect();
187
+ this.connect();
188
+ }
189
+
178
190
  shutdown() {
179
191
  if (this._timer) this._timer.cancel();
180
192
  this.disconnect();