gestalt-mobile 0.55.1 → 0.55.3
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/dist/server/server/features/sessions/session-events/endpoint.js +26 -1
- package/dist/server/server/platform/maintenance/managed-upgrade.js +1 -1
- package/dist/server/server/platform/retrieval/managed-xerj.js +2 -2
- package/dist/server/server/platform/retrieval/xerj-index-config.js +7 -4
- package/package.json +1 -1
|
@@ -8,7 +8,12 @@ import { isSlowClient } from '../../../platform/events/slow-client.js';
|
|
|
8
8
|
import { installWebSocketHeartbeat } from '../../../platform/events/websocket-heartbeat.js';
|
|
9
9
|
export function registerSessionEvents(app, deps) {
|
|
10
10
|
const server = new WebSocketServer({ noServer: true });
|
|
11
|
+
let closing = false;
|
|
11
12
|
app.server.on('upgrade', (request, socket, head) => {
|
|
13
|
+
if (closing) {
|
|
14
|
+
socket.destroy();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
12
17
|
const url = new URL(request.url ?? '/', 'http://relay.invalid');
|
|
13
18
|
const match = /^\/api\/sessions\/([^/]+)\/events$/.exec(url.pathname);
|
|
14
19
|
const after = Number(url.searchParams.get('after') ?? '0');
|
|
@@ -79,5 +84,25 @@ export function registerSessionEvents(app, deps) {
|
|
|
79
84
|
connection.on('close', cleanup);
|
|
80
85
|
});
|
|
81
86
|
});
|
|
82
|
-
|
|
87
|
+
// HTTP shutdown waits for upgraded sockets, so onClose is too late to drain
|
|
88
|
+
// them. Bound the close handshake so an offline browser cannot block restart.
|
|
89
|
+
app.addHook('preClose', async () => {
|
|
90
|
+
closing = true;
|
|
91
|
+
await new Promise((resolve, reject) => {
|
|
92
|
+
const timeout = setTimeout(() => {
|
|
93
|
+
for (const connection of server.clients)
|
|
94
|
+
connection.terminate();
|
|
95
|
+
}, 1_000);
|
|
96
|
+
timeout.unref();
|
|
97
|
+
server.close((error) => {
|
|
98
|
+
clearTimeout(timeout);
|
|
99
|
+
if (error)
|
|
100
|
+
reject(error);
|
|
101
|
+
else
|
|
102
|
+
resolve();
|
|
103
|
+
});
|
|
104
|
+
for (const connection of server.clients)
|
|
105
|
+
connection.close(1012, 'service restart');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
83
108
|
}
|
|
@@ -48,7 +48,7 @@ export class ManagedUpgrade {
|
|
|
48
48
|
throw new Error('A managed Mobile restart descriptor is required');
|
|
49
49
|
}
|
|
50
50
|
this.current = { instanceId: this.current.instanceId, phase: 'updating' };
|
|
51
|
-
this.starting = this.run('gestalt', ['update-restart'], {
|
|
51
|
+
this.starting = this.run(this.environment.GESTALT_MANAGER_BIN || 'gestalt', ['update-restart'], {
|
|
52
52
|
cwd: this.cwd,
|
|
53
53
|
env: this.environment,
|
|
54
54
|
timeout: 15_000,
|
|
@@ -7,7 +7,6 @@ import { spawn } from 'node:child_process';
|
|
|
7
7
|
import { access } from 'node:fs/promises';
|
|
8
8
|
import { constants } from 'node:fs';
|
|
9
9
|
import { isAbsolute, join } from 'node:path';
|
|
10
|
-
export const managedXerjVersion = '1.0.0-rc.87';
|
|
11
10
|
/** The manager alone owns backend identity, authentication and shared lifetime. */
|
|
12
11
|
export class ManagedXerj {
|
|
13
12
|
environment;
|
|
@@ -69,7 +68,8 @@ export class ManagedXerj {
|
|
|
69
68
|
if (value.status === 'unavailable')
|
|
70
69
|
return settle(unavailable('managed-backend-unavailable'));
|
|
71
70
|
if (value.status !== 'ready' ||
|
|
72
|
-
value.version !==
|
|
71
|
+
typeof value.version !== 'string' ||
|
|
72
|
+
!/^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][A-Za-z0-9.-]+)?$/.test(value.version) ||
|
|
73
73
|
typeof value.endpoint !== 'string' ||
|
|
74
74
|
!/^http:\/\/(127\.0\.0\.1|\[::1\])(?::\d{1,5})?$/.test(value.endpoint))
|
|
75
75
|
throw new Error();
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
import { createHash, randomUUID } from 'node:crypto';
|
|
7
7
|
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
|
-
|
|
10
|
-
// Content-affecting rc.87 settings. Reused in the command and fingerprint so
|
|
9
|
+
// Content-affecting settings. Reused in the command and fingerprint so
|
|
11
10
|
// changing an operational setting cannot accidentally require a rebuild.
|
|
12
11
|
export const xerjContentArguments = [
|
|
13
12
|
'--no-graph',
|
|
@@ -24,7 +23,6 @@ export function xerjIndexConfig(root, prefix, endpoint) {
|
|
|
24
23
|
root,
|
|
25
24
|
prefix,
|
|
26
25
|
endpoint,
|
|
27
|
-
nativeVersion: managedXerjVersion,
|
|
28
26
|
contentArguments: xerjContentArguments,
|
|
29
27
|
followSymlinks: false,
|
|
30
28
|
label: null,
|
|
@@ -40,8 +38,13 @@ const filename = '.gestalt-index-config.json';
|
|
|
40
38
|
export async function checkXerjIndexConfig(directory, expected) {
|
|
41
39
|
try {
|
|
42
40
|
const saved = JSON.parse(await readFile(join(directory, filename), 'utf8'));
|
|
41
|
+
// Older fingerprints included a pinned version. Validate their integrity
|
|
42
|
+
// before comparing content settings; native XERJ owns index compatibility.
|
|
43
|
+
const settings = { ...saved.settings };
|
|
44
|
+
delete settings.nativeVersion;
|
|
43
45
|
return saved.schemaVersion === expected.schemaVersion &&
|
|
44
|
-
|
|
46
|
+
createHash('sha256').update(JSON.stringify(settings)).digest('hex') ===
|
|
47
|
+
expected.fingerprint &&
|
|
45
48
|
createHash('sha256').update(JSON.stringify(saved.settings)).digest('hex') ===
|
|
46
49
|
saved.fingerprint
|
|
47
50
|
? 'compatible'
|