@volter/teams 0.1.68 → 0.1.69
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/package.json +1 -1
- package/session-follow.mjs +11 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/teams",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.69",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Volter Teams, the neutral team plane: machine identity and daemon core, the local door and server link, admission from machine grants, product doors, and the Teams server's neutral routes (company RFC 0008).",
|
|
6
6
|
"license": "MIT",
|
package/session-follow.mjs
CHANGED
|
@@ -43,14 +43,21 @@ export function followTeamSession({ origin, teamId, sessionId, token, tail = 300
|
|
|
43
43
|
while (!controller.signal.aborted) {
|
|
44
44
|
const connection = new AbortController();
|
|
45
45
|
following = connection;
|
|
46
|
-
let reader;
|
|
46
|
+
let reader, opening;
|
|
47
|
+
let openTimedOut = false;
|
|
47
48
|
try {
|
|
48
49
|
if (!cursor) cursor = String((await read()).event_cursor ?? '') || null;
|
|
49
|
-
const
|
|
50
|
+
const auth = await headers();
|
|
51
|
+
// Limit the HTTP opening, not the lifetime of a healthy SSE response.
|
|
52
|
+
// A stream may remain quiet while a session waits for input.
|
|
53
|
+
opening = setTimeout(() => { openTimedOut = true; connection.abort(); }, 15000);
|
|
54
|
+
const response = await fetchImpl(`${base}/events?${cursor ? `after=${encodeURIComponent(cursor)}` : 'tail=1'}`, { headers: auth, signal: AbortSignal.any([controller.signal, connection.signal]) });
|
|
55
|
+
clearTimeout(opening);
|
|
50
56
|
if (!response.ok) {
|
|
51
57
|
// The event door uses 409 when this cursor is outside its retained
|
|
52
58
|
// journal (including after a server restart). Retrying it cannot help.
|
|
53
59
|
if (response.status === 409) cursor = null;
|
|
60
|
+
await response.body?.cancel().catch(() => {});
|
|
54
61
|
throw failure('follow', response.status, `following the session failed (${response.status})`);
|
|
55
62
|
}
|
|
56
63
|
onLive(true);
|
|
@@ -94,8 +101,9 @@ export function followTeamSession({ origin, teamId, sessionId, token, tail = 300
|
|
|
94
101
|
}
|
|
95
102
|
} catch (error) {
|
|
96
103
|
if (controller.signal.aborted) return;
|
|
97
|
-
if (!connection.signal.aborted) onError({ stage: error.stage ?? 'follow', status: error.status ?? null, message: error.message, snapshot: observed });
|
|
104
|
+
if (!connection.signal.aborted || openTimedOut) onError({ stage: error.stage ?? 'follow', status: error.status ?? null, message: openTimedOut ? 'Following the session did not connect before the deadline' : error.message, snapshot: observed });
|
|
98
105
|
} finally {
|
|
106
|
+
clearTimeout(opening);
|
|
99
107
|
if (following === connection) following = null;
|
|
100
108
|
connection.abort();
|
|
101
109
|
await reader?.cancel().catch(() => {});
|