@seriousgaming/sdk-tools 1.12.0 → 1.12.1

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  DevShell
4
- } from "./cli-RQISHMJF.js";
4
+ } from "./cli-EG2VP7IV.js";
5
5
  import "./cli-BWX5E7TQ.js";
6
6
  import "./cli-JD563OF4.js";
7
7
  import "./cli-ILKCQNM6.js";
@@ -1989,6 +1989,7 @@ function viewMessages(page, state, options) {
1989
1989
 
1990
1990
  // cli/dev/shell.ts
1991
1991
  var LOOPBACK = "127.0.0.1";
1992
+ var KEEP_ALIVE_MS = 25e3;
1992
1993
  var REINITIALISING_CAUSES = /* @__PURE__ */ new Set([
1993
1994
  "reinitialise",
1994
1995
  "reconfigure",
@@ -2047,6 +2048,9 @@ var DevShell = class {
2047
2048
  /** One socket per viewer page, each carrying only what that page is owed. */
2048
2049
  viewSockets = null;
2049
2050
  views = /* @__PURE__ */ new Map();
2051
+ keepAlive = null;
2052
+ /** Sockets pinged since they last answered one. */
2053
+ unanswered = /* @__PURE__ */ new WeakSet();
2050
2054
  /** Teams processing a round, per run (§12.4.4); `-1` is the cohort. */
2051
2055
  processing = /* @__PURE__ */ new Map();
2052
2056
  vite = null;
@@ -2152,6 +2156,8 @@ var DevShell = class {
2152
2156
  async stop() {
2153
2157
  await this.watcher?.close();
2154
2158
  this.watcher = null;
2159
+ if (this.keepAlive) clearInterval(this.keepAlive);
2160
+ this.keepAlive = null;
2155
2161
  this.sockets?.clients.forEach((client) => client.close());
2156
2162
  this.sockets?.close();
2157
2163
  this.viewSockets?.clients.forEach((client) => client.close());
@@ -2605,13 +2611,12 @@ Install the package's dependencies to serve its surfaces.
2605
2611
  socket.destroy();
2606
2612
  return;
2607
2613
  }
2608
- target.handleUpgrade(
2609
- request,
2610
- socket,
2611
- head,
2612
- (client) => target.emit("connection", client, request)
2613
- );
2614
+ target.handleUpgrade(request, socket, head, (client) => {
2615
+ client.on("pong", () => this.unanswered.delete(client));
2616
+ target.emit("connection", client, request);
2617
+ });
2614
2618
  });
2619
+ this.keepSocketsAlive();
2615
2620
  this.session.subscribe((event) => {
2616
2621
  this.broadcast(event, "session");
2617
2622
  this.updateViews(event, "session");
@@ -2667,6 +2672,28 @@ Install the package's dependencies to serve its surfaces.
2667
2672
  });
2668
2673
  });
2669
2674
  }
2675
+ /**
2676
+ * Ping every console and viewer socket, and drop one that left the last
2677
+ * ping unanswered. A proxy in front of the server closes a connection
2678
+ * that carries nothing for long enough (60s on an AWS load balancer), and
2679
+ * an idle session sends nothing; a peer that vanished without closing is
2680
+ * otherwise never noticed (#847).
2681
+ */
2682
+ keepSocketsAlive() {
2683
+ this.keepAlive = setInterval(() => {
2684
+ for (const server of [this.sockets, this.viewSockets]) {
2685
+ for (const client of server?.clients ?? []) {
2686
+ if (this.unanswered.has(client)) {
2687
+ client.terminate();
2688
+ continue;
2689
+ }
2690
+ this.unanswered.add(client);
2691
+ client.ping();
2692
+ }
2693
+ }
2694
+ }, this.options.keepAliveMs ?? KEEP_ALIVE_MS);
2695
+ this.keepAlive.unref();
2696
+ }
2670
2697
  async receive(socket, raw) {
2671
2698
  let envelope;
2672
2699
  try {
@@ -7,7 +7,7 @@ import {
7
7
  DevShell,
8
8
  LOCAL_ORIGINS_FLAG,
9
9
  parseRoute
10
- } from "./cli-RQISHMJF.js";
10
+ } from "./cli-EG2VP7IV.js";
11
11
  import "./cli-BWX5E7TQ.js";
12
12
  import "./cli-JD563OF4.js";
13
13
  import "./cli-ILKCQNM6.js";
package/dist/cli.js CHANGED
@@ -146,7 +146,7 @@ var configPathCommand = lazy(() => import("./cli-HCJLYI24.js"), "configPathComma
146
146
  var configSetCommand = lazy(() => import("./cli-HCJLYI24.js"), "configSetCommand");
147
147
  var configureCommand = lazy(() => import("./cli-HAFCFY77.js"), "configureCommand");
148
148
  var deleteCommand = lazy(() => import("./cli-SEEOQVUL.js"), "deleteCommand");
149
- var devCommand = lazy(() => import("./cli-OMG4E53H.js"), "devCommand");
149
+ var devCommand = lazy(() => import("./cli-7224T6HG.js"), "devCommand");
150
150
  var devStatusCommand = lazy(() => import("./cli-BCXGOLU3.js"), "devStatusCommand");
151
151
  var devStopCommand = lazy(() => import("./cli-BCXGOLU3.js"), "devStopCommand");
152
152
  var docsCommand = lazy(() => import("./cli-DAHR7PKB.js"), "docsCommand");
@@ -174,7 +174,7 @@ var packageVersionCommand = lazy(
174
174
  );
175
175
  var patchCommand = lazy(() => import("./cli-R2DFD6ZZ.js"), "patchCommand");
176
176
  var resolveCommand = lazy(() => import("./cli-LCYUBCVY.js"), "resolveCommand");
177
- var screenshotCommand = lazy(() => import("./cli-QK7QAP5H.js"), "screenshotCommand");
177
+ var screenshotCommand = lazy(() => import("./cli-WCFZNEK2.js"), "screenshotCommand");
178
178
  var clockAdvanceCommand = lazy(() => import("./cli-FTLH4WCE.js"), "clockAdvanceCommand");
179
179
  var faultCommand = lazy(() => import("./cli-FTLH4WCE.js"), "faultCommand");
180
180
  var localeCommand = lazy(() => import("./cli-FTLH4WCE.js"), "localeCommand");
package/dist/client.js CHANGED
@@ -34021,6 +34021,7 @@ function viewMessages(page, state2, options) {
34021
34021
 
34022
34022
  // cli/dev/shell.ts
34023
34023
  var LOOPBACK = "127.0.0.1";
34024
+ var KEEP_ALIVE_MS = 25e3;
34024
34025
  var REINITIALISING_CAUSES = /* @__PURE__ */ new Set([
34025
34026
  "reinitialise",
34026
34027
  "reconfigure",
@@ -34079,6 +34080,9 @@ var DevShell = class {
34079
34080
  /** One socket per viewer page, each carrying only what that page is owed. */
34080
34081
  viewSockets = null;
34081
34082
  views = /* @__PURE__ */ new Map();
34083
+ keepAlive = null;
34084
+ /** Sockets pinged since they last answered one. */
34085
+ unanswered = /* @__PURE__ */ new WeakSet();
34082
34086
  /** Teams processing a round, per run (§12.4.4); `-1` is the cohort. */
34083
34087
  processing = /* @__PURE__ */ new Map();
34084
34088
  vite = null;
@@ -34184,6 +34188,8 @@ var DevShell = class {
34184
34188
  async stop() {
34185
34189
  await this.watcher?.close();
34186
34190
  this.watcher = null;
34191
+ if (this.keepAlive) clearInterval(this.keepAlive);
34192
+ this.keepAlive = null;
34187
34193
  this.sockets?.clients.forEach((client) => client.close());
34188
34194
  this.sockets?.close();
34189
34195
  this.viewSockets?.clients.forEach((client) => client.close());
@@ -34637,13 +34643,12 @@ Install the package's dependencies to serve its surfaces.
34637
34643
  socket.destroy();
34638
34644
  return;
34639
34645
  }
34640
- target.handleUpgrade(
34641
- request,
34642
- socket,
34643
- head,
34644
- (client) => target.emit("connection", client, request)
34645
- );
34646
+ target.handleUpgrade(request, socket, head, (client) => {
34647
+ client.on("pong", () => this.unanswered.delete(client));
34648
+ target.emit("connection", client, request);
34649
+ });
34646
34650
  });
34651
+ this.keepSocketsAlive();
34647
34652
  this.session.subscribe((event) => {
34648
34653
  this.broadcast(event, "session");
34649
34654
  this.updateViews(event, "session");
@@ -34699,6 +34704,28 @@ Install the package's dependencies to serve its surfaces.
34699
34704
  });
34700
34705
  });
34701
34706
  }
34707
+ /**
34708
+ * Ping every console and viewer socket, and drop one that left the last
34709
+ * ping unanswered. A proxy in front of the server closes a connection
34710
+ * that carries nothing for long enough (60s on an AWS load balancer), and
34711
+ * an idle session sends nothing; a peer that vanished without closing is
34712
+ * otherwise never noticed (#847).
34713
+ */
34714
+ keepSocketsAlive() {
34715
+ this.keepAlive = setInterval(() => {
34716
+ for (const server of [this.sockets, this.viewSockets]) {
34717
+ for (const client of server?.clients ?? []) {
34718
+ if (this.unanswered.has(client)) {
34719
+ client.terminate();
34720
+ continue;
34721
+ }
34722
+ this.unanswered.add(client);
34723
+ client.ping();
34724
+ }
34725
+ }
34726
+ }, this.options.keepAliveMs ?? KEEP_ALIVE_MS);
34727
+ this.keepAlive.unref();
34728
+ }
34702
34729
  async receive(socket, raw) {
34703
34730
  let envelope;
34704
34731
  try {
@@ -73,6 +73,8 @@ export interface ShellOptions extends SessionOptions, PublicOrigins {
73
73
  * worker's server would otherwise compile the same surfaces again.
74
74
  */
75
75
  builtSurfaces?: string;
76
+ /** How often each console and viewer socket is pinged. For tests. */
77
+ keepAliveMs?: number;
76
78
  }
77
79
  /**
78
80
  * Something the server could not apply live, kept until it no longer holds so
@@ -122,6 +124,9 @@ export declare class DevShell {
122
124
  /** One socket per viewer page, each carrying only what that page is owed. */
123
125
  private viewSockets;
124
126
  private readonly views;
127
+ private keepAlive;
128
+ /** Sockets pinged since they last answered one. */
129
+ private readonly unanswered;
125
130
  /** Teams processing a round, per run (§12.4.4); `-1` is the cohort. */
126
131
  private readonly processing;
127
132
  private vite;
@@ -275,6 +280,14 @@ export declare class DevShell {
275
280
  */
276
281
  private viteServerOptions;
277
282
  private attachSockets;
283
+ /**
284
+ * Ping every console and viewer socket, and drop one that left the last
285
+ * ping unanswered. A proxy in front of the server closes a connection
286
+ * that carries nothing for long enough (60s on an AWS load balancer), and
287
+ * an idle session sends nothing; a peer that vanished without closing is
288
+ * otherwise never noticed (#847).
289
+ */
290
+ private keepSocketsAlive;
278
291
  private receive;
279
292
  /** What one viewer page is owed, now. */
280
293
  private viewOf;
@@ -37,6 +37,12 @@ own copies, so read those lines for every release you cross.
37
37
 
38
38
  ## [Unreleased]
39
39
 
40
+ ## [1.12.1] — 2026-11-17
41
+
42
+ ### Fixed
43
+
44
+ - `sdk dev` no longer loses its connection to the console and surfaces every idle minute when it is served behind a proxy or load balancer that closes quiet connections, such as an AWS load balancer. The server now pings each connection every 25 seconds, and drops one whose browser has stopped answering (#847)
45
+
40
46
  ## [1.12.0] — 2026-11-16
41
47
 
42
48
  ### Added
@@ -33745,6 +33745,7 @@ function viewMessages(page, state2, options) {
33745
33745
 
33746
33746
  // cli/dev/shell.ts
33747
33747
  var LOOPBACK = "127.0.0.1";
33748
+ var KEEP_ALIVE_MS = 25e3;
33748
33749
  var REINITIALISING_CAUSES = /* @__PURE__ */ new Set([
33749
33750
  "reinitialise",
33750
33751
  "reconfigure",
@@ -33803,6 +33804,9 @@ var DevShell = class {
33803
33804
  /** One socket per viewer page, each carrying only what that page is owed. */
33804
33805
  viewSockets = null;
33805
33806
  views = /* @__PURE__ */ new Map();
33807
+ keepAlive = null;
33808
+ /** Sockets pinged since they last answered one. */
33809
+ unanswered = /* @__PURE__ */ new WeakSet();
33806
33810
  /** Teams processing a round, per run (§12.4.4); `-1` is the cohort. */
33807
33811
  processing = /* @__PURE__ */ new Map();
33808
33812
  vite = null;
@@ -33908,6 +33912,8 @@ var DevShell = class {
33908
33912
  async stop() {
33909
33913
  await this.watcher?.close();
33910
33914
  this.watcher = null;
33915
+ if (this.keepAlive) clearInterval(this.keepAlive);
33916
+ this.keepAlive = null;
33911
33917
  this.sockets?.clients.forEach((client) => client.close());
33912
33918
  this.sockets?.close();
33913
33919
  this.viewSockets?.clients.forEach((client) => client.close());
@@ -34361,13 +34367,12 @@ Install the package's dependencies to serve its surfaces.
34361
34367
  socket.destroy();
34362
34368
  return;
34363
34369
  }
34364
- target.handleUpgrade(
34365
- request,
34366
- socket,
34367
- head,
34368
- (client) => target.emit("connection", client, request)
34369
- );
34370
+ target.handleUpgrade(request, socket, head, (client) => {
34371
+ client.on("pong", () => this.unanswered.delete(client));
34372
+ target.emit("connection", client, request);
34373
+ });
34370
34374
  });
34375
+ this.keepSocketsAlive();
34371
34376
  this.session.subscribe((event) => {
34372
34377
  this.broadcast(event, "session");
34373
34378
  this.updateViews(event, "session");
@@ -34423,6 +34428,28 @@ Install the package's dependencies to serve its surfaces.
34423
34428
  });
34424
34429
  });
34425
34430
  }
34431
+ /**
34432
+ * Ping every console and viewer socket, and drop one that left the last
34433
+ * ping unanswered. A proxy in front of the server closes a connection
34434
+ * that carries nothing for long enough (60s on an AWS load balancer), and
34435
+ * an idle session sends nothing; a peer that vanished without closing is
34436
+ * otherwise never noticed (#847).
34437
+ */
34438
+ keepSocketsAlive() {
34439
+ this.keepAlive = setInterval(() => {
34440
+ for (const server of [this.sockets, this.viewSockets]) {
34441
+ for (const client of server?.clients ?? []) {
34442
+ if (this.unanswered.has(client)) {
34443
+ client.terminate();
34444
+ continue;
34445
+ }
34446
+ this.unanswered.add(client);
34447
+ client.ping();
34448
+ }
34449
+ }
34450
+ }, this.options.keepAliveMs ?? KEEP_ALIVE_MS);
34451
+ this.keepAlive.unref();
34452
+ }
34426
34453
  async receive(socket, raw) {
34427
34454
  let envelope;
34428
34455
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seriousgaming/sdk-tools",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "SDK tooling for building Serious Gaming games",
5
5
  "homepage": "https://sdk.seriousgaming.com/",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -82,7 +82,7 @@
82
82
  "@mui/icons-material": "^9.5.0",
83
83
  "@mui/material": "^9.5.0",
84
84
  "@playwright/test": "^1.64.1",
85
- "@seriousgaming/sdk": "1.12.0",
85
+ "@seriousgaming/sdk": "1.12.1",
86
86
  "@testing-library/jest-dom": "^7.0.1",
87
87
  "@testing-library/react": "^16.3.3",
88
88
  "@types/express": "^5.0.6",
@@ -111,7 +111,7 @@
111
111
  },
112
112
  "peerDependencies": {
113
113
  "@playwright/test": ">=1.50.0",
114
- "@seriousgaming/sdk": "^1.12.0"
114
+ "@seriousgaming/sdk": "^1.12.1"
115
115
  },
116
116
  "peerDependenciesMeta": {
117
117
  "@playwright/test": {