@oblax/realtime 0.0.0-stage → 2.1.0
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/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/realtime-module.d.ts +59 -0
- package/dist/realtime-module.d.ts.map +1 -0
- package/dist/realtime-module.js +95 -0
- package/dist/realtime-module.js.map +1 -0
- package/dist/sse.d.ts +49 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +101 -0
- package/dist/sse.js.map +1 -0
- package/dist/stream.d.ts +125 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +471 -0
- package/dist/stream.js.map +1 -0
- package/dist/types.d.ts +167 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -3
- package/README.md +0 -3
package/dist/stream.js
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import { OblaxHttpError, OblaxTimeoutError } from '@oblax/core';
|
|
2
|
+
import { OblaxRealtimeError } from './errors.js';
|
|
3
|
+
import { SseParser } from './sse.js';
|
|
4
|
+
/** The frame a stream ends with when the token behind its ticket expired. */
|
|
5
|
+
const EVENT_EXPIRED = 'oblax.stream.expired';
|
|
6
|
+
/** The frame a stream ends with when the server closes it; its data names the reason. */
|
|
7
|
+
const EVENT_CLOSING = 'oblax.stream.closing';
|
|
8
|
+
/** The stream's own system events: never passed to the app's handlers. */
|
|
9
|
+
const SYSTEM_PREFIX = 'oblax.stream.';
|
|
10
|
+
/** A stream open this long worked: the next failure starts the backoff over. */
|
|
11
|
+
const STABLE_AFTER = 30000;
|
|
12
|
+
/**
|
|
13
|
+
* An open realtime stream: it gets a ticket, opens the stream, dispatches
|
|
14
|
+
* events to its handlers, and reconnects (new ticket, new stream) until it's
|
|
15
|
+
* closed. Created by `oblax.realtime.connect()`, which starts it at once.
|
|
16
|
+
*
|
|
17
|
+
* Every `on…` method returns a function that removes the handler. Handlers may
|
|
18
|
+
* be added and removed while events are dispatched; one that throws is reported
|
|
19
|
+
* to `onError` (`source: 'handler'`) and the stream carries on.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const stream = oblax.realtime.connect<{ 'invoice.ready': { invoice_id: string } }>()
|
|
24
|
+
* stream.onOpen(() => reloadInvoices()) // after every connect: nothing is replayed
|
|
25
|
+
* stream.on('invoice.ready', (e) => reloadInvoice(e.data.invoice_id))
|
|
26
|
+
* // on sign-out
|
|
27
|
+
* stream.close()
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export class RealtimeStream {
|
|
31
|
+
/** @internal Use `oblax.realtime.connect()`. */
|
|
32
|
+
constructor(ctx, settings) {
|
|
33
|
+
this.current = 'connecting';
|
|
34
|
+
/** Aborted by close(): ends the attempt in flight and any wait. */
|
|
35
|
+
this.stopper = new AbortController();
|
|
36
|
+
this.timers = new Set();
|
|
37
|
+
this.onSignalAbort = () => this.close();
|
|
38
|
+
this.eventHandlers = new Map();
|
|
39
|
+
this.anyHandlers = new Set();
|
|
40
|
+
this.openHandlers = new Set();
|
|
41
|
+
this.closeHandlers = new Set();
|
|
42
|
+
this.errorHandlers = new Set();
|
|
43
|
+
/** Failed attempts in a row: drives the backoff. */
|
|
44
|
+
this.failures = 0;
|
|
45
|
+
/** A stream opened at least once: the next open is a reconnect. */
|
|
46
|
+
this.opened = false;
|
|
47
|
+
this.ctx = ctx;
|
|
48
|
+
this.settings = settings;
|
|
49
|
+
// Started on the next microtask, so handlers added right after connect()
|
|
50
|
+
// see everything, even a close for an already aborted signal.
|
|
51
|
+
const signal = settings.signal;
|
|
52
|
+
if (signal?.aborted) {
|
|
53
|
+
void Promise.resolve().then(() => this.close());
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
signal?.addEventListener('abort', this.onSignalAbort, { once: true });
|
|
57
|
+
void Promise.resolve().then(() => this.run());
|
|
58
|
+
}
|
|
59
|
+
/** Where the stream is: `connecting`, `open`, `reconnecting` or `closed`. */
|
|
60
|
+
get state() {
|
|
61
|
+
return this.current;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Calls `handler` for each event named `event`. The stream's own system
|
|
65
|
+
* events (`oblax.stream.*`) never reach it.
|
|
66
|
+
* @returns a function that removes the handler.
|
|
67
|
+
*/
|
|
68
|
+
on(event, handler) {
|
|
69
|
+
if (this.isClosed)
|
|
70
|
+
return noop;
|
|
71
|
+
let set = this.eventHandlers.get(event);
|
|
72
|
+
if (!set) {
|
|
73
|
+
set = new Set();
|
|
74
|
+
this.eventHandlers.set(event, set);
|
|
75
|
+
}
|
|
76
|
+
const h = handler;
|
|
77
|
+
set.add(h);
|
|
78
|
+
return () => {
|
|
79
|
+
const current = this.eventHandlers.get(event);
|
|
80
|
+
current?.delete(h);
|
|
81
|
+
if (current?.size === 0)
|
|
82
|
+
this.eventHandlers.delete(event);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Calls `handler` for every event, after the handlers for its name.
|
|
87
|
+
* @returns a function that removes the handler.
|
|
88
|
+
*/
|
|
89
|
+
onAny(handler) {
|
|
90
|
+
return this.add(this.anyHandlers, handler);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Calls `handler` each time a stream opens, the first time and after every
|
|
94
|
+
* reconnect. Events sent while the stream was down are gone: refetch what
|
|
95
|
+
* the page shows here.
|
|
96
|
+
* @returns a function that removes the handler.
|
|
97
|
+
*/
|
|
98
|
+
onOpen(handler) {
|
|
99
|
+
return this.add(this.openHandlers, handler);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Calls `handler` once, when the stream closes for good: `closed` (by the
|
|
103
|
+
* app), `replaced` or `fatal`. It doesn't fire for a reconnect.
|
|
104
|
+
* @returns a function that removes the handler.
|
|
105
|
+
*/
|
|
106
|
+
onClose(handler) {
|
|
107
|
+
return this.add(this.closeHandlers, handler);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Calls `handler` for every failed attempt (`fatal: false` with `retryIn`
|
|
111
|
+
* when it retries; `fatal: true` right before a fatal close) and for every
|
|
112
|
+
* error thrown by one of the app's handlers (`source: 'handler'`). HTTP
|
|
113
|
+
* failures are `OblaxHttpError`s; others are `OblaxRealtimeError`,
|
|
114
|
+
* `OblaxTimeoutError` or the runtime's network error.
|
|
115
|
+
* @returns a function that removes the handler.
|
|
116
|
+
*/
|
|
117
|
+
onError(handler) {
|
|
118
|
+
return this.add(this.errorHandlers, handler);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Closes the stream for good: aborts the request in flight, clears every
|
|
122
|
+
* timer and calls `onClose({ reason: 'closed' })`. Safe to call more than once.
|
|
123
|
+
*/
|
|
124
|
+
close() {
|
|
125
|
+
this.finish({ reason: 'closed' });
|
|
126
|
+
}
|
|
127
|
+
// ─── Connection loop ────────────────────────────────────────────────────────
|
|
128
|
+
get isClosed() {
|
|
129
|
+
return this.current === 'closed';
|
|
130
|
+
}
|
|
131
|
+
async run() {
|
|
132
|
+
while (!this.isClosed) {
|
|
133
|
+
const outcome = await this.attempt();
|
|
134
|
+
if (this.isClosed || outcome.kind === 'stopped')
|
|
135
|
+
return;
|
|
136
|
+
if (outcome.kind === 'ended' && outcome.reason === 'replaced') {
|
|
137
|
+
this.finish({ reason: 'replaced' });
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (outcome.kind === 'failed' && outcome.fatal) {
|
|
141
|
+
this.report(outcome.error, { source: outcome.source, fatal: true });
|
|
142
|
+
this.finish({ reason: 'fatal', error: outcome.error });
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.current = this.opened ? 'reconnecting' : 'connecting';
|
|
146
|
+
// a stream that stayed open worked: start the backoff over
|
|
147
|
+
const stable = outcome.openedFor >= STABLE_AFTER;
|
|
148
|
+
if (stable)
|
|
149
|
+
this.failures = 0;
|
|
150
|
+
let delay;
|
|
151
|
+
if (outcome.kind === 'failed') {
|
|
152
|
+
delay = this.backoff(++this.failures);
|
|
153
|
+
this.report(outcome.error, { source: outcome.source, fatal: false, retryIn: delay });
|
|
154
|
+
}
|
|
155
|
+
else if (outcome.reason === 'expired') {
|
|
156
|
+
// the token behind the ticket expired: reconnect at once. The ticket
|
|
157
|
+
// request then answers 401 AUTH_TOKEN_EXPIRED, and the HTTP client runs
|
|
158
|
+
// its single-flight refresh and retries: streams that expire together
|
|
159
|
+
// never refresh twice. A stream that expired right away backs off.
|
|
160
|
+
delay = stable ? 0 : this.backoff(++this.failures);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
// shutdown: the pod is going away. The jitter spreads its clients out.
|
|
164
|
+
delay = stable ? this.backoff(1) : this.backoff(++this.failures);
|
|
165
|
+
}
|
|
166
|
+
await this.wait(delay);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** One ticket and one stream, read until it ends. */
|
|
170
|
+
async attempt() {
|
|
171
|
+
const controller = new AbortController();
|
|
172
|
+
const abort = () => controller.abort();
|
|
173
|
+
this.stopper.signal.addEventListener('abort', abort, { once: true });
|
|
174
|
+
try {
|
|
175
|
+
return await this.connectOnce(controller);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
return this.isClosed ? { kind: 'stopped' } : { kind: 'failed', error, source: 'stream', fatal: false, openedFor: 0 };
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
this.stopper.signal.removeEventListener('abort', abort);
|
|
182
|
+
// releases the connection, whatever ended the attempt
|
|
183
|
+
controller.abort();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async connectOnce(controller) {
|
|
187
|
+
if (typeof fetch !== 'function' || typeof TextDecoder !== 'function') {
|
|
188
|
+
return failed(new OblaxRealtimeError('unsupported', 'Realtime needs fetch and TextDecoder, which this runtime lacks.'), 'stream', true);
|
|
189
|
+
}
|
|
190
|
+
// 1. A ticket, through the SDK's HTTP client: platform auth, client id,
|
|
191
|
+
// timeout, and the refresh on 401 (an expired token).
|
|
192
|
+
let ticket;
|
|
193
|
+
try {
|
|
194
|
+
ticket = await this.postTicket(controller.signal);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
if (this.isClosed)
|
|
198
|
+
return { kind: 'stopped' };
|
|
199
|
+
return failed(error, 'ticket', isFatalStatus(error));
|
|
200
|
+
}
|
|
201
|
+
// 2. The stream. The ticket is the credential: no platform auth, no cookies.
|
|
202
|
+
const { endpoint, version, clientId, timeout } = this.ctx.config;
|
|
203
|
+
const url = `${endpoint}/api/${version}/realtime/stream` +
|
|
204
|
+
`?ticket=${encodeURIComponent(ticket)}&oblax_client_id=${encodeURIComponent(clientId)}`;
|
|
205
|
+
// the timeout covers the answer's headers (and an error's body), not the stream
|
|
206
|
+
let timedOut = false;
|
|
207
|
+
const headersTimer = this.setTimer(() => {
|
|
208
|
+
timedOut = true;
|
|
209
|
+
controller.abort();
|
|
210
|
+
}, timeout);
|
|
211
|
+
let response;
|
|
212
|
+
try {
|
|
213
|
+
response = await fetch(url, {
|
|
214
|
+
method: 'GET',
|
|
215
|
+
// Accept is required: without it the API compresses the answer and holds it back
|
|
216
|
+
headers: { Accept: 'text/event-stream', 'oblax-client-id': clientId },
|
|
217
|
+
credentials: 'omit',
|
|
218
|
+
signal: controller.signal,
|
|
219
|
+
});
|
|
220
|
+
if (!response.ok) {
|
|
221
|
+
const error = await httpError(response);
|
|
222
|
+
return failed(error, 'stream', isFatalStatus(error));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
if (this.isClosed)
|
|
227
|
+
return { kind: 'stopped' };
|
|
228
|
+
return failed(timedOut ? new OblaxTimeoutError(timeout) : error, 'stream', false);
|
|
229
|
+
}
|
|
230
|
+
finally {
|
|
231
|
+
this.clearTimer(headersTimer);
|
|
232
|
+
}
|
|
233
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
234
|
+
if (!contentType.includes('text/event-stream')) {
|
|
235
|
+
return failed(new OblaxRealtimeError('bad_response', `Expected an event stream, got "${contentType}".`), 'stream', false);
|
|
236
|
+
}
|
|
237
|
+
if (!response.body || typeof response.body.getReader !== 'function') {
|
|
238
|
+
return failed(new OblaxRealtimeError('unsupported', "This runtime's fetch can't stream a response body (React Native's can't): realtime isn't supported here."), 'stream', true);
|
|
239
|
+
}
|
|
240
|
+
// 3. Open: tell the app, then read until the stream ends.
|
|
241
|
+
const openedAt = Date.now();
|
|
242
|
+
const reconnected = this.opened;
|
|
243
|
+
this.opened = true;
|
|
244
|
+
this.current = 'open';
|
|
245
|
+
this.emit(this.openHandlers, { reconnected });
|
|
246
|
+
if (this.isClosed)
|
|
247
|
+
return { kind: 'stopped' };
|
|
248
|
+
const end = await this.read(response.body, controller);
|
|
249
|
+
const openedFor = Date.now() - openedAt;
|
|
250
|
+
if (this.isClosed)
|
|
251
|
+
return { kind: 'stopped' };
|
|
252
|
+
if (typeof end === 'string')
|
|
253
|
+
return { kind: 'ended', reason: end, openedFor };
|
|
254
|
+
return { kind: 'failed', error: end.error, source: 'stream', fatal: false, openedFor };
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Gets a ticket. An expired token answers 401 `AUTH_TOKEN_EXPIRED`, which
|
|
258
|
+
* the HTTP client refreshes and retries once; a 401 left after that (no
|
|
259
|
+
* refresh to be had, or another request's refresh was already running) is
|
|
260
|
+
* retried with backoff. A 403 means not signed in, a visitor or not allowed:
|
|
261
|
+
* fatal, with no refresh.
|
|
262
|
+
*/
|
|
263
|
+
async postTicket(signal) {
|
|
264
|
+
const res = await this.ctx.http.post('/realtime/tickets', undefined, { signal });
|
|
265
|
+
if (typeof res?.ticket !== 'string' || res.ticket === '') {
|
|
266
|
+
throw new OblaxRealtimeError('bad_response', 'The ticket answer has no ticket.');
|
|
267
|
+
}
|
|
268
|
+
return res.ticket;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Reads frames until the stream ends: the reason a close frame gave, or the
|
|
272
|
+
* error (no close frame, silence, the network). A watchdog aborts the
|
|
273
|
+
* request when nothing, not even a ping, arrived for `idleTimeout`.
|
|
274
|
+
*/
|
|
275
|
+
async read(body, controller) {
|
|
276
|
+
const reader = body.getReader();
|
|
277
|
+
const status = { end: null, silent: false };
|
|
278
|
+
const parser = new SseParser((frame) => {
|
|
279
|
+
if (status.end === null && !this.isClosed)
|
|
280
|
+
status.end = this.handleFrame(frame);
|
|
281
|
+
});
|
|
282
|
+
let watchdog;
|
|
283
|
+
const arm = () => {
|
|
284
|
+
this.clearTimer(watchdog);
|
|
285
|
+
watchdog = this.setTimer(() => {
|
|
286
|
+
status.silent = true;
|
|
287
|
+
controller.abort();
|
|
288
|
+
}, this.settings.idleTimeout);
|
|
289
|
+
};
|
|
290
|
+
arm();
|
|
291
|
+
try {
|
|
292
|
+
for (;;) {
|
|
293
|
+
const { value, done } = await reader.read();
|
|
294
|
+
if (done) {
|
|
295
|
+
return { error: new OblaxRealtimeError('stream_ended', 'The stream ended without a close frame.') };
|
|
296
|
+
}
|
|
297
|
+
arm();
|
|
298
|
+
if (value)
|
|
299
|
+
parser.push(value);
|
|
300
|
+
if (status.end !== null)
|
|
301
|
+
return status.end;
|
|
302
|
+
if (this.isClosed)
|
|
303
|
+
return { error: undefined };
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
if (status.silent) {
|
|
308
|
+
return {
|
|
309
|
+
error: new OblaxRealtimeError('stream_silent', `Nothing arrived on the stream for ${this.settings.idleTimeout}ms.`),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
return { error };
|
|
313
|
+
}
|
|
314
|
+
finally {
|
|
315
|
+
this.clearTimer(watchdog);
|
|
316
|
+
reader.cancel().catch(noop);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/** Dispatches an app event; returns why the stream ends for a close frame. */
|
|
320
|
+
handleFrame(frame) {
|
|
321
|
+
if (frame.event === EVENT_EXPIRED)
|
|
322
|
+
return 'expired';
|
|
323
|
+
if (frame.event === EVENT_CLOSING) {
|
|
324
|
+
const data = parseData(frame.data);
|
|
325
|
+
const reason = typeof data === 'object' && data !== null ? data.reason : undefined;
|
|
326
|
+
// an unknown reason is taken as a shutdown: reconnecting is the safe side
|
|
327
|
+
return reason === 'replaced' ? 'replaced' : 'shutdown';
|
|
328
|
+
}
|
|
329
|
+
if (frame.event.startsWith(SYSTEM_PREFIX))
|
|
330
|
+
return null;
|
|
331
|
+
const event = { id: frame.id ?? '', event: frame.event, data: parseData(frame.data) };
|
|
332
|
+
const named = this.eventHandlers.get(event.event);
|
|
333
|
+
if (named)
|
|
334
|
+
this.emit(named, event);
|
|
335
|
+
this.emit(this.anyHandlers, event);
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
339
|
+
/** The delay before attempt `n` of a run of failures: doubling, capped, with jitter. */
|
|
340
|
+
backoff(n) {
|
|
341
|
+
const { reconnectDelay, maxReconnectDelay } = this.settings;
|
|
342
|
+
const ceiling = Math.min(maxReconnectDelay, reconnectDelay * 2 ** Math.min(n - 1, 30));
|
|
343
|
+
return Math.round(ceiling * (0.5 + Math.random() / 2));
|
|
344
|
+
}
|
|
345
|
+
/** Resolves after `ms`, or at once when the stream closes. */
|
|
346
|
+
wait(ms) {
|
|
347
|
+
return new Promise((resolve) => {
|
|
348
|
+
const signal = this.stopper.signal;
|
|
349
|
+
if (signal.aborted) {
|
|
350
|
+
resolve();
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const done = () => {
|
|
354
|
+
this.clearTimer(timer);
|
|
355
|
+
signal.removeEventListener('abort', done);
|
|
356
|
+
resolve();
|
|
357
|
+
};
|
|
358
|
+
const timer = this.setTimer(done, ms);
|
|
359
|
+
signal.addEventListener('abort', done, { once: true });
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
setTimer(fn, ms) {
|
|
363
|
+
const timer = setTimeout(() => {
|
|
364
|
+
this.timers.delete(timer);
|
|
365
|
+
fn();
|
|
366
|
+
}, ms);
|
|
367
|
+
this.timers.add(timer);
|
|
368
|
+
return timer;
|
|
369
|
+
}
|
|
370
|
+
clearTimer(timer) {
|
|
371
|
+
if (timer === undefined)
|
|
372
|
+
return;
|
|
373
|
+
clearTimeout(timer);
|
|
374
|
+
this.timers.delete(timer);
|
|
375
|
+
}
|
|
376
|
+
add(set, handler) {
|
|
377
|
+
if (this.isClosed)
|
|
378
|
+
return noop;
|
|
379
|
+
set.add(handler);
|
|
380
|
+
return () => {
|
|
381
|
+
set.delete(handler);
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Calls each handler of a snapshot, skipping one removed meanwhile, and
|
|
386
|
+
* stopping when a handler closed the stream (except for close handlers).
|
|
387
|
+
*/
|
|
388
|
+
emit(set, value, whenClosed = false) {
|
|
389
|
+
for (const handler of [...set]) {
|
|
390
|
+
if (!set.has(handler))
|
|
391
|
+
continue;
|
|
392
|
+
if (this.isClosed && !whenClosed)
|
|
393
|
+
return;
|
|
394
|
+
try {
|
|
395
|
+
handler(value);
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
this.report(error, { source: 'handler', fatal: false });
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/** Calls the error handlers; one that throws is ignored, there's nowhere left to report it. */
|
|
403
|
+
report(error, info) {
|
|
404
|
+
for (const handler of [...this.errorHandlers]) {
|
|
405
|
+
if (!this.errorHandlers.has(handler))
|
|
406
|
+
continue;
|
|
407
|
+
try {
|
|
408
|
+
handler(error, info);
|
|
409
|
+
}
|
|
410
|
+
catch {
|
|
411
|
+
// swallowed: reporting it to onError again could loop
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
/** Closes for good, once: stops the attempt and timers, then calls the close handlers. */
|
|
416
|
+
finish(info) {
|
|
417
|
+
if (this.isClosed)
|
|
418
|
+
return;
|
|
419
|
+
this.current = 'closed';
|
|
420
|
+
this.stopper.abort();
|
|
421
|
+
for (const timer of this.timers)
|
|
422
|
+
clearTimeout(timer);
|
|
423
|
+
this.timers.clear();
|
|
424
|
+
this.settings.signal?.removeEventListener('abort', this.onSignalAbort);
|
|
425
|
+
this.emit(this.closeHandlers, info, true);
|
|
426
|
+
this.eventHandlers.clear();
|
|
427
|
+
this.anyHandlers.clear();
|
|
428
|
+
this.openHandlers.clear();
|
|
429
|
+
this.closeHandlers.clear();
|
|
430
|
+
this.errorHandlers.clear();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
function noop() { }
|
|
434
|
+
function failed(error, source, fatal) {
|
|
435
|
+
return { kind: 'failed', error, source, fatal, openedFor: 0 };
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* A 4xx that a retry can't fix: 400 (a bad client id), 403 (not signed in, a
|
|
439
|
+
* visitor, not allowed), 404 and the like. 401 (a spent ticket, or an expired
|
|
440
|
+
* token the HTTP client couldn't refresh), 408 and 429 are retried, as are 5xx
|
|
441
|
+
* and network errors.
|
|
442
|
+
*/
|
|
443
|
+
function isFatalStatus(error) {
|
|
444
|
+
if (!(error instanceof OblaxHttpError))
|
|
445
|
+
return false;
|
|
446
|
+
const s = error.status;
|
|
447
|
+
return s >= 400 && s < 500 && s !== 401 && s !== 408 && s !== 429;
|
|
448
|
+
}
|
|
449
|
+
/** An event's data: parsed JSON, or the raw string when it isn't JSON. */
|
|
450
|
+
function parseData(raw) {
|
|
451
|
+
try {
|
|
452
|
+
return JSON.parse(raw);
|
|
453
|
+
}
|
|
454
|
+
catch {
|
|
455
|
+
return raw;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
/** The error a refused stream answered, as the HTTP client builds it. */
|
|
459
|
+
async function httpError(response) {
|
|
460
|
+
try {
|
|
461
|
+
const body = (await response.json());
|
|
462
|
+
const message = typeof body === 'object' && body !== null && typeof body.message === 'string'
|
|
463
|
+
? body.message
|
|
464
|
+
: response.statusText;
|
|
465
|
+
return new OblaxHttpError(response.status, message, body);
|
|
466
|
+
}
|
|
467
|
+
catch {
|
|
468
|
+
return new OblaxHttpError(response.status, response.statusText);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAcpC,6EAA6E;AAC7E,MAAM,aAAa,GAAG,sBAAsB,CAAA;AAC5C,yFAAyF;AACzF,MAAM,aAAa,GAAG,sBAAsB,CAAA;AAC5C,0EAA0E;AAC1E,MAAM,aAAa,GAAG,eAAe,CAAA;AACrC,gFAAgF;AAChF,MAAM,YAAY,GAAG,KAAM,CAAA;AAqB3B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,cAAc;IAoBzB,gDAAgD;IAChD,YAAY,GAAiB,EAAE,QAAwB;QApB/C,YAAO,GAAgB,YAAY,CAAA;QAG3C,mEAAmE;QAClD,YAAO,GAAG,IAAI,eAAe,EAAE,CAAA;QAC/B,WAAM,GAAG,IAAI,GAAG,EAAiC,CAAA;QACjD,kBAAa,GAAG,GAAS,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;QAExC,kBAAa,GAAG,IAAI,GAAG,EAAuC,CAAA;QAC9D,gBAAW,GAAG,IAAI,GAAG,EAA0B,CAA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AI,CAAC,CAAA;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAA;IACjE,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reconnect and liveness tuning. Set module-wide defaults with
|
|
3
|
+
* `Realtime(config)`, or per stream with `connect(options)`.
|
|
4
|
+
*/
|
|
5
|
+
export interface RealtimeConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The first reconnect delay in milliseconds, after a stream that failed or
|
|
8
|
+
* dropped. Each failure in a row doubles it, up to `maxReconnectDelay`; every
|
|
9
|
+
* delay gets jitter (50–100% of it), so a pod's clients don't return at once.
|
|
10
|
+
* @default 1000
|
|
11
|
+
*/
|
|
12
|
+
reconnectDelay?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The longest reconnect delay in milliseconds.
|
|
15
|
+
* @default 30000
|
|
16
|
+
*/
|
|
17
|
+
maxReconnectDelay?: number;
|
|
18
|
+
/**
|
|
19
|
+
* How long an open stream may stay silent, in milliseconds, before it's taken
|
|
20
|
+
* for dead and reconnected. The server pings every 25 seconds, so this catches
|
|
21
|
+
* half-open connections that would otherwise wait forever.
|
|
22
|
+
* @default 60000
|
|
23
|
+
*/
|
|
24
|
+
idleTimeout?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Options for `oblax.realtime.connect()`. */
|
|
27
|
+
export interface ConnectOptions extends RealtimeConfig {
|
|
28
|
+
/** Aborting it closes the stream for good, as `stream.close()` does. */
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Maps event names to the type of their `data`, to type `stream.on()`:
|
|
33
|
+
*
|
|
34
|
+
* ```typescript
|
|
35
|
+
* type Events = { 'invoice.ready': { invoice_id: string } }
|
|
36
|
+
* const stream = oblax.realtime.connect<Events>()
|
|
37
|
+
* stream.on('invoice.ready', (e) => e.data.invoice_id) // string
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* An interface works as well as a type alias.
|
|
41
|
+
*/
|
|
42
|
+
export type RealtimeEventMap = Record<string, any>;
|
|
43
|
+
/**
|
|
44
|
+
* The map an untyped `connect()` uses: any event name, `data` typed `any`.
|
|
45
|
+
*/
|
|
46
|
+
export type UntypedEvents = Record<string, any>;
|
|
47
|
+
/** An event as it arrives on the stream. */
|
|
48
|
+
export interface RealtimeEvent<TName extends string = string, TData = unknown> {
|
|
49
|
+
/** The event's id (an xid): what `send()` answered for it. */
|
|
50
|
+
readonly id: string;
|
|
51
|
+
/** The name the sender chose. */
|
|
52
|
+
readonly event: TName;
|
|
53
|
+
/**
|
|
54
|
+
* The sent data, parsed from JSON; `null` for a send without data. If it
|
|
55
|
+
* isn't JSON (it always is from Oblax), the raw string.
|
|
56
|
+
*/
|
|
57
|
+
readonly data: TData;
|
|
58
|
+
}
|
|
59
|
+
/** Any event of the map, as `onAny()` receives it: a union discriminated by `event`. */
|
|
60
|
+
export type AnyRealtimeEvent<E extends RealtimeEventMap> = {
|
|
61
|
+
[K in keyof E & string]: RealtimeEvent<K, E[K]>;
|
|
62
|
+
}[keyof E & string];
|
|
63
|
+
/**
|
|
64
|
+
* Where a stream is:
|
|
65
|
+
*
|
|
66
|
+
* - `connecting` — before it first opened, retries included;
|
|
67
|
+
* - `open` — events are arriving;
|
|
68
|
+
* - `reconnecting` — it was open, and is getting a new ticket and stream;
|
|
69
|
+
* - `closed` — for good: closed by the app, replaced, or a fatal error.
|
|
70
|
+
*/
|
|
71
|
+
export type StreamState = 'connecting' | 'open' | 'reconnecting' | 'closed';
|
|
72
|
+
/**
|
|
73
|
+
* Why a stream closed for good:
|
|
74
|
+
*
|
|
75
|
+
* - `closed` — the app called `close()`, or aborted the `signal`;
|
|
76
|
+
* - `replaced` — the user opened too many streams (more than 10 on one
|
|
77
|
+
* server), so the server closed this, the oldest. It isn't reconnected,
|
|
78
|
+
* which would close another of the user's streams in turn;
|
|
79
|
+
* - `fatal` — reconnecting can't help: the user isn't signed in, is a
|
|
80
|
+
* visitor or isn't allowed to connect, the client id is wrong, or the
|
|
81
|
+
* runtime can't stream (React Native). `error` says which.
|
|
82
|
+
*/
|
|
83
|
+
export type CloseReason = 'closed' | 'replaced' | 'fatal';
|
|
84
|
+
/** What `onOpen` handlers get. */
|
|
85
|
+
export interface OpenInfo {
|
|
86
|
+
/**
|
|
87
|
+
* `true` on every open after the first. Nothing sent while the stream was
|
|
88
|
+
* down is replayed: refetch what the page shows.
|
|
89
|
+
*/
|
|
90
|
+
reconnected: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** What `onClose` handlers get. */
|
|
93
|
+
export interface CloseInfo {
|
|
94
|
+
reason: CloseReason;
|
|
95
|
+
/** The error that closed the stream, for `fatal`. */
|
|
96
|
+
error?: unknown;
|
|
97
|
+
}
|
|
98
|
+
/** What failed, for `onError`. */
|
|
99
|
+
export type StreamErrorSource =
|
|
100
|
+
/** Getting a ticket (`POST /realtime/tickets`). */
|
|
101
|
+
'ticket'
|
|
102
|
+
/** Opening or reading the stream. */
|
|
103
|
+
| 'stream'
|
|
104
|
+
/** One of the app's own handlers threw. The stream carries on. */
|
|
105
|
+
| 'handler';
|
|
106
|
+
/** What `onError` handlers get with the error. */
|
|
107
|
+
export interface StreamErrorInfo {
|
|
108
|
+
source: StreamErrorSource;
|
|
109
|
+
/**
|
|
110
|
+
* `true` when the stream gives up: `onClose({ reason: 'fatal' })` follows.
|
|
111
|
+
* `false` when it retries (or, for a handler, carries on).
|
|
112
|
+
*/
|
|
113
|
+
fatal: boolean;
|
|
114
|
+
/** Milliseconds until the next attempt, when it retries. */
|
|
115
|
+
retryIn?: number;
|
|
116
|
+
}
|
|
117
|
+
/** The lists a target can name. A stream gets an event once if it matches any. */
|
|
118
|
+
export interface RealtimeTargetLists {
|
|
119
|
+
/** Person (user) ids. */
|
|
120
|
+
users?: string[];
|
|
121
|
+
/** Session ids: a login, shared by every tab of it. */
|
|
122
|
+
sessions?: string[];
|
|
123
|
+
/** Role names, e.g. `admin`. */
|
|
124
|
+
roles?: string[];
|
|
125
|
+
/** Organization ids: their members when the stream opened. */
|
|
126
|
+
organizations?: string[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Who gets an event: `{ all: true }` (every open stream of the project
|
|
130
|
+
* environment), or one or more lists, never both. The project and environment
|
|
131
|
+
* are always the sender's own. An empty target is refused by the server (400
|
|
132
|
+
* `target: required`), not by this type.
|
|
133
|
+
*/
|
|
134
|
+
export type RealtimeTarget = ({
|
|
135
|
+
all: true;
|
|
136
|
+
} & {
|
|
137
|
+
[K in keyof RealtimeTargetLists]?: never;
|
|
138
|
+
}) | (RealtimeTargetLists & {
|
|
139
|
+
all?: never;
|
|
140
|
+
});
|
|
141
|
+
/** Params for `oblax.realtime.send()`. */
|
|
142
|
+
export interface SendEventParams {
|
|
143
|
+
/**
|
|
144
|
+
* The event's name: lowercase, starting with a letter, up to 64 of
|
|
145
|
+
* `a-z 0-9 _ . -`. The `oblax.` prefix is reserved.
|
|
146
|
+
* @example 'invoice.ready'
|
|
147
|
+
*/
|
|
148
|
+
event: string;
|
|
149
|
+
/**
|
|
150
|
+
* Any JSON, at most 4 KB as compact JSON. Sent as-is: keys are not renamed.
|
|
151
|
+
* Send ids, not records; omitted, it arrives as `null`.
|
|
152
|
+
*/
|
|
153
|
+
data?: unknown;
|
|
154
|
+
target: RealtimeTarget;
|
|
155
|
+
}
|
|
156
|
+
/** The answer to a send: accepted and published, not delivered. */
|
|
157
|
+
export interface SendEventResult {
|
|
158
|
+
/** The event's id, as the receiving streams see it. */
|
|
159
|
+
id: string;
|
|
160
|
+
}
|
|
161
|
+
/** The answer to a ticket request. */
|
|
162
|
+
export interface Ticket {
|
|
163
|
+
ticket: string;
|
|
164
|
+
/** Seconds the ticket can be redeemed for. */
|
|
165
|
+
expires_in: number;
|
|
166
|
+
}
|
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