nowity 1.9.0 → 1.11.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/README.md +124 -16
- package/dist/client/clock.d.ts +98 -0
- package/dist/client/clock.d.ts.map +1 -0
- package/dist/client/clock.js +154 -0
- package/dist/client/devtools.d.ts +64 -1
- package/dist/client/devtools.d.ts.map +1 -1
- package/dist/client/devtools.js +134 -22
- package/dist/client/nowity-client.d.ts +38 -0
- package/dist/client/nowity-client.d.ts.map +1 -1
- package/dist/client/nowity-client.js +93 -3
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -1
- package/dist/core/protocol.d.ts +70 -2
- package/dist/core/protocol.d.ts.map +1 -1
- package/dist/core/types.d.ts +13 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/devtools.d.ts +14 -1
- package/dist/devtools.d.ts.map +1 -1
- package/dist/devtools.js +64 -18
- package/dist/server/api/configure.d.ts +5 -1
- package/dist/server/api/configure.d.ts.map +1 -1
- package/dist/server/api/configure.js +2 -0
- package/dist/server/change-source/change-source.d.ts +23 -5
- package/dist/server/change-source/change-source.d.ts.map +1 -1
- package/dist/server/change-source/outbox-change-source.d.ts +47 -12
- package/dist/server/change-source/outbox-change-source.d.ts.map +1 -1
- package/dist/server/change-source/outbox-change-source.js +154 -65
- package/dist/server/change-source/pg-snapshot.d.ts +25 -0
- package/dist/server/change-source/pg-snapshot.d.ts.map +1 -0
- package/dist/server/change-source/pg-snapshot.js +43 -0
- package/dist/server/sync-engine.d.ts +119 -0
- package/dist/server/sync-engine.d.ts.map +1 -1
- package/dist/server/sync-engine.js +445 -117
- package/dist/server/ws-server.d.ts +28 -0
- package/dist/server/ws-server.d.ts.map +1 -1
- package/dist/server/ws-server.js +112 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -635,8 +635,8 @@ Three things follow from it being the database that coordinates:
|
|
|
635
635
|
- **Connections are sticky, but only for their lifetime.** A socket lives on one
|
|
636
636
|
instance; a client that reconnects elsewhere resends its subscriptions and
|
|
637
637
|
continues its mutation sequence from where the database says it got to.
|
|
638
|
-
- **A new instance starts from now.** It resumes
|
|
639
|
-
rather than replaying history, and its clients are still correct because a
|
|
638
|
+
- **A new instance starts from now.** It resumes from the snapshot its engine
|
|
639
|
+
started in rather than replaying history, and its clients are still correct because a
|
|
640
640
|
subscription's first answer is a snapshot of the database, not a replay of the
|
|
641
641
|
stream.
|
|
642
642
|
- **Retention waits for the slowest live reader.** `nowity.nowity_prune_outbox` deletes
|
|
@@ -984,8 +984,67 @@ const { NowityDevtoolsPanel } = await import("nowity/devtools");
|
|
|
984
984
|
```
|
|
985
985
|
|
|
986
986
|
Table with a waterfall, filter by type, search, sort by any column, details of a
|
|
987
|
-
row, copy as JSON, clear.
|
|
988
|
-
in it yet.
|
|
987
|
+
row, copy as JSON, clear. Snapshot timing (queue, snapshot, database) of a
|
|
988
|
+
subscription is not in it yet.
|
|
989
|
+
|
|
990
|
+
#### The server's clock
|
|
991
|
+
|
|
992
|
+
Client and server times come from different clocks, so the client keeps an
|
|
993
|
+
estimate of the server's, NTP-style. The welcome is the first sample (the
|
|
994
|
+
server stamps when the hello arrived and when the welcome left), then a burst
|
|
995
|
+
of three `ping`s, then one every 30 s:
|
|
996
|
+
|
|
997
|
+
```
|
|
998
|
+
offset = ((t1 − t0) + (t2 − t3)) / 2 server time = client time + offset
|
|
999
|
+
rtt = (t3 − t0) − (t2 − t1) the true offset is within ± rtt / 2
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
The estimate is the sample with the smallest round trip of the last 8 (none
|
|
1003
|
+
older than 5 min), so one slow exchange does not move it. Client times are
|
|
1004
|
+
`performance.now()`, which the system clock being set does not touch; a sample
|
|
1005
|
+
whose bound contradicts older ones (a suspended laptop, a stepped server clock)
|
|
1006
|
+
drops them, so the estimate corrects itself on the next exchange. Pings are
|
|
1007
|
+
answered on arrival, ahead of whatever the socket has queued.
|
|
1008
|
+
|
|
1009
|
+
```ts
|
|
1010
|
+
client.clock.offsetMs; // null until synced
|
|
1011
|
+
client.clock.rttMs; // of the sample the offset comes from
|
|
1012
|
+
client.clock.uncertaintyMs; // rttMs / 2
|
|
1013
|
+
client.clock.sampleCount;
|
|
1014
|
+
client.clock.syncedAt; // performance.now() of the newest sample
|
|
1015
|
+
client.clock.toServerTime(performance.now());
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
`clock: { intervalMs, burst, samples, maxAgeMs }` tunes it, `clock: false` sends
|
|
1019
|
+
no pings. A server older than this gets none either way and the clock stays
|
|
1020
|
+
unsynced.
|
|
1021
|
+
|
|
1022
|
+
Every devtools record carries `serverTs` (its `ts` on the server's clock) and
|
|
1023
|
+
`uncertaintyMs`; records from before the first sample get them with it. The
|
|
1024
|
+
panel draws its axis on the server's clock through one offset, the current
|
|
1025
|
+
estimate, for every row — each record's own stamp may come from an older
|
|
1026
|
+
estimate, and mixing them could swap records a few ms apart.
|
|
1027
|
+
|
|
1028
|
+
#### Server timing of a write
|
|
1029
|
+
|
|
1030
|
+
```ts
|
|
1031
|
+
createNowityServer({
|
|
1032
|
+
syncServer: { timing: (session) => isAdmin(session.userId) },
|
|
1033
|
+
});
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
Off by default. `true`, or a function decided once per connection at its hello
|
|
1037
|
+
(a failure means off). A connection with timing gets, on the server's clock,
|
|
1038
|
+
`timing` on every `mutation-result` — `receivedAt` (on the socket), `startedAt`
|
|
1039
|
+
(its turn in the connection's queue), `committedAt`, `sentAt` — and on every
|
|
1040
|
+
`tx` — `writtenAt` (its own earliest outbox row, the *database's* clock),
|
|
1041
|
+
`readAt` (handed over by the change source; for the `tx` that carries the
|
|
1042
|
+
writer's own data with the ack, the commit), `fanOutAt`, `sentAt`. The recorder
|
|
1043
|
+
keeps them on the mutation (`meta.server`, and `meta.push` with `meta.dataAt`
|
|
1044
|
+
from the first data that included it), and `mutationPhases(record)` lays the
|
|
1045
|
+
whole round on one axis: sent → received → started → written → committed →
|
|
1046
|
+
answered → read → fan-out → pushed → data, client times with their ± uncertainty.
|
|
1047
|
+
The detail of a mutation in the panel shows exactly that.
|
|
989
1048
|
|
|
990
1049
|
### Escape hatches
|
|
991
1050
|
|
|
@@ -1038,15 +1097,23 @@ sees the full `OLD` row — which the WAL does not, unless you opt into
|
|
|
1038
1097
|
`bigserial` alone is not a usable cursor: sequence values are handed out before
|
|
1039
1098
|
commit, so ordering by `seq` can walk past a row whose transaction commits later,
|
|
1040
1099
|
and `seq > cursor` would then hide it forever. Every outbox row therefore also
|
|
1041
|
-
stores `pg_current_xact_id()`, and the
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1100
|
+
stores `pg_current_xact_id()`, and the cursor is a *snapshot*
|
|
1101
|
+
(`pg_current_snapshot()`): "every transaction it sees has been delivered". A read
|
|
1102
|
+
returns the rows of the transactions its own statement snapshot sees and the
|
|
1103
|
+
cursor does not (`pg_visible_in_snapshot`), and that snapshot becomes the cursor.
|
|
1104
|
+
Each transaction becomes visible in exactly one such interval, so nothing is
|
|
1105
|
+
skipped and nothing is read twice.
|
|
1106
|
+
|
|
1107
|
+
Up to 1.10 the cursor was the oldest transaction still in flight
|
|
1108
|
+
(`pg_snapshot_xmin`), and one long write transaction anywhere in the database
|
|
1109
|
+
held every change behind it. With the snapshot cursor a transaction in flight is
|
|
1110
|
+
just not seen yet; the rest flows past it and its rows arrive after its commit
|
|
1111
|
+
(scenario 34e).
|
|
1112
|
+
|
|
1113
|
+
The same property closes the snapshot/stream hole: the engine starts from the
|
|
1114
|
+
snapshot its starting state was read in, and every later snapshot sees at least
|
|
1115
|
+
what the cursor sees. Anything a snapshot does not see is not under the cursor
|
|
1116
|
+
and gets streamed. Delivery is
|
|
1050
1117
|
at-least-once; because patches come from re-running the query and diffing, a replay
|
|
1051
1118
|
produces an empty diff, so the client observes exactly once.
|
|
1052
1119
|
|
|
@@ -1070,11 +1137,52 @@ snapshot there: the fan-out, the first answer of a subscription, server-side
|
|
|
1070
1137
|
rendering in that process. The engine fans out one batch at a time, so a pool of
|
|
1071
1138
|
a few connections is plenty.
|
|
1072
1139
|
|
|
1140
|
+
### Parallel fan-out (1.11)
|
|
1141
|
+
|
|
1142
|
+
A batch with a lot to recompute is spread over several snapshots at once:
|
|
1143
|
+
`createNowityServer({ fanOut: { concurrency, minPerSnapshot } })`, default 4
|
|
1144
|
+
snapshots and one per 8 recomputations, so a small batch still takes one. A
|
|
1145
|
+
session is never split between two snapshots — a client never sees half of a
|
|
1146
|
+
transaction — and batches still go out one after another, so the patches of one
|
|
1147
|
+
subscription keep their order. Each snapshot is a connection of the snapshot
|
|
1148
|
+
pool: size the pool to `concurrency` plus whatever subscribes, acks and
|
|
1149
|
+
server-side rendering need alongside.
|
|
1150
|
+
|
|
1151
|
+
### The writer's data comes with the ack (1.11)
|
|
1152
|
+
|
|
1153
|
+
A mutation reads, in its own transaction and in the same statement that moves
|
|
1154
|
+
`last_mutation_id`, what the capture trigger put in the outbox for it. Right
|
|
1155
|
+
after the commit the engine recomputes the writer's subscriptions those writes
|
|
1156
|
+
can reach and sends them as a `tx` — with `lastMutationId` = the mutation —
|
|
1157
|
+
immediately before `mutation-result`. The client needs nothing new: the `tx`
|
|
1158
|
+
confirms the mutation and drops its optimistic copy, the result resolves the
|
|
1159
|
+
promise. When the stream later carries the same transaction, the writer's
|
|
1160
|
+
subscriptions remember the snapshot the ack read in, see the transaction in it
|
|
1161
|
+
and are skipped (`engine.stats.skipped`); a batch that also carries something
|
|
1162
|
+
newer is recomputed and diffed as usual, so the writer is never sent the same
|
|
1163
|
+
state twice.
|
|
1164
|
+
|
|
1165
|
+
The ack is all or nothing and falls back to the stream when it cannot be
|
|
1166
|
+
complete: a write to a permission table (the invalidation path stays the
|
|
1167
|
+
stream's), a subscribe of the same connection still being evaluated, a change
|
|
1168
|
+
source that cannot say what a transaction wrote (WAL), or `ackWithState: false`.
|
|
1169
|
+
Its snapshots and recomputations are counted apart (`stats.acks`,
|
|
1170
|
+
`ackSnapshots`, `ackEvaluations`). Other clients get the transaction through the
|
|
1171
|
+
stream as before.
|
|
1172
|
+
|
|
1173
|
+
Mutations of one socket no longer queue behind its subscribes: they keep their
|
|
1174
|
+
order among themselves and wait for the socket's `hello`, but a slow subscribe
|
|
1175
|
+
in front of them does not hold them up. The start of a mutation's transaction is
|
|
1176
|
+
one statement instead of three (create-or-lock the client row and stamp the
|
|
1177
|
+
transaction).
|
|
1178
|
+
|
|
1073
1179
|
## Known limitations
|
|
1074
1180
|
|
|
1075
|
-
- **A long-running write transaction
|
|
1076
|
-
|
|
1077
|
-
|
|
1181
|
+
- **A long-running write transaction costs the outbox reads index range.** It no
|
|
1182
|
+
longer stalls the stream (1.11), but every read scans the outbox from the oldest
|
|
1183
|
+
xid in flight in its cursor, so a transaction open for minutes makes each read
|
|
1184
|
+
walk the rows written since it began (filtered out by visibility). It also holds
|
|
1185
|
+
retention back, as before.
|
|
1078
1186
|
- **Incremental view maintenance is naive**: on a relevant change the query is
|
|
1079
1187
|
re-executed and its result diffed. Correct for any query, O(result size) per
|
|
1080
1188
|
change. Which subscriptions are *relevant* is now decided by row rather than by
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The server's clock, as seen from this page.
|
|
3
|
+
*
|
|
4
|
+
* Client and server times come from different clocks, so the moment a mutation
|
|
5
|
+
* left the browser and the moment the server committed it cannot be put on one
|
|
6
|
+
* axis by subtraction. This estimates the difference NTP-style from exchanges
|
|
7
|
+
* the client starts itself (the hello, then `ping`s):
|
|
8
|
+
*
|
|
9
|
+
* t0 client sends t1 server receives
|
|
10
|
+
* t3 client receives t2 server answers
|
|
11
|
+
*
|
|
12
|
+
* offset = ((t1 - t0) + (t2 - t3)) / 2 server = client + offset
|
|
13
|
+
* rtt = (t3 - t0) - (t2 - t1) the time spent on the wire
|
|
14
|
+
*
|
|
15
|
+
* The true offset lies within `offset ± rtt / 2` of every sample, whatever the
|
|
16
|
+
* asymmetry of the path. A sample with a small round trip is therefore a tight
|
|
17
|
+
* bound, and the estimate is the one with the smallest RTT of the recent ones —
|
|
18
|
+
* a single slow exchange (a busy socket, a radio waking up) does not move it.
|
|
19
|
+
*
|
|
20
|
+
* Client times are `performance.now()`, never `Date.now()`: the page's own
|
|
21
|
+
* monotonic clock, which a user changing the system time — or NTP stepping it
|
|
22
|
+
* — does not move. What can still move is the relation between the two clocks
|
|
23
|
+
* (a suspended laptop, a server whose clock was stepped). A new sample whose
|
|
24
|
+
* bound does not overlap an older one's proves that older one stale, and it is
|
|
25
|
+
* dropped — so the estimate corrects itself on the next exchange instead of
|
|
26
|
+
* clinging to a tight but outdated sample.
|
|
27
|
+
*/
|
|
28
|
+
export interface ClockSample {
|
|
29
|
+
/** Client send / receive, `performance.now()`. */
|
|
30
|
+
t0: number;
|
|
31
|
+
t3: number;
|
|
32
|
+
/** Server receive / send, the server's epoch milliseconds. */
|
|
33
|
+
t1: number;
|
|
34
|
+
t2: number;
|
|
35
|
+
offsetMs: number;
|
|
36
|
+
rttMs: number;
|
|
37
|
+
}
|
|
38
|
+
/** What the estimate stands on, for a panel and for an export. */
|
|
39
|
+
export interface ClockState {
|
|
40
|
+
/** server time = client time + `offsetMs`; `null` until the first sample. */
|
|
41
|
+
offsetMs: number | null;
|
|
42
|
+
/** Round trip of the sample the offset comes from. */
|
|
43
|
+
rttMs: number | null;
|
|
44
|
+
/** How far off the offset may be: `rttMs / 2`. */
|
|
45
|
+
uncertaintyMs: number | null;
|
|
46
|
+
/** Samples the estimate is chosen from now. */
|
|
47
|
+
sampleCount: number;
|
|
48
|
+
/** Samples taken in this page, including those dropped since. */
|
|
49
|
+
totalSamples: number;
|
|
50
|
+
/** Client time (`performance.now()`) of the newest sample. */
|
|
51
|
+
syncedAt: number | null;
|
|
52
|
+
}
|
|
53
|
+
export interface ServerClockOptions {
|
|
54
|
+
/** Recent samples the estimate is chosen from. Default 8. */
|
|
55
|
+
samples?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Oldest sample still used, in ms. Two quartz clocks drift apart by tens of
|
|
58
|
+
* ppm, so a tight sample from long ago is no longer tight. Default 5 min.
|
|
59
|
+
*/
|
|
60
|
+
maxAgeMs?: number;
|
|
61
|
+
/** Client clock. Default `performance.now()`. */
|
|
62
|
+
now?: () => number;
|
|
63
|
+
}
|
|
64
|
+
export declare const DEFAULT_CLOCK_SAMPLES = 8;
|
|
65
|
+
export declare const DEFAULT_CLOCK_MAX_AGE_MS: number;
|
|
66
|
+
/** One exchange, or `null` when it cannot be one (an answer received before it was asked). */
|
|
67
|
+
export declare function clockSample(t0: number, t1: number, t2: number, t3: number): ClockSample | null;
|
|
68
|
+
export declare class ServerClock {
|
|
69
|
+
private readonly limit;
|
|
70
|
+
private readonly maxAgeMs;
|
|
71
|
+
readonly now: () => number;
|
|
72
|
+
private samples;
|
|
73
|
+
private best;
|
|
74
|
+
private total;
|
|
75
|
+
private readonly listeners;
|
|
76
|
+
constructor(opts?: ServerClockOptions);
|
|
77
|
+
/** Take one exchange into the estimate; returns it, or `null` when it was not usable. */
|
|
78
|
+
addSample(t0: number, t1: number, t2: number, t3: number): ClockSample | null;
|
|
79
|
+
/** Forget every sample — the estimate starts again with the next one. */
|
|
80
|
+
reset(): void;
|
|
81
|
+
get synced(): boolean;
|
|
82
|
+
get offsetMs(): number | null;
|
|
83
|
+
get rttMs(): number | null;
|
|
84
|
+
get uncertaintyMs(): number | null;
|
|
85
|
+
get sampleCount(): number;
|
|
86
|
+
get syncedAt(): number | null;
|
|
87
|
+
state(): ClockState;
|
|
88
|
+
/** A client time (`performance.now()`) on the server's clock, or `null` before the first sample. */
|
|
89
|
+
toServerTime(clientTs: number): number | null;
|
|
90
|
+
/** A server time on this page's `performance.now()` clock, or `null` before the first sample. */
|
|
91
|
+
toClientTime(serverTs: number): number | null;
|
|
92
|
+
/** The server's clock now, as well as it is known. */
|
|
93
|
+
serverNow(): number | null;
|
|
94
|
+
/** Told after every change of the estimate. Returns the unsubscribe. */
|
|
95
|
+
subscribe(listener: () => void): () => void;
|
|
96
|
+
private changed;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=clock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../src/client/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,WAAW;IACxB,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACvB,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,sDAAsD;IACtD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,kDAAkD;IAClD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IAC/B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,wBAAwB,QAAa,CAAC;AAUnD,8FAA8F;AAC9F,w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3C,OAAO,CAAC,OAAO;CASlB"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The server's clock, as seen from this page.
|
|
4
|
+
*
|
|
5
|
+
* Client and server times come from different clocks, so the moment a mutation
|
|
6
|
+
* left the browser and the moment the server committed it cannot be put on one
|
|
7
|
+
* axis by subtraction. This estimates the difference NTP-style from exchanges
|
|
8
|
+
* the client starts itself (the hello, then `ping`s):
|
|
9
|
+
*
|
|
10
|
+
* t0 client sends t1 server receives
|
|
11
|
+
* t3 client receives t2 server answers
|
|
12
|
+
*
|
|
13
|
+
* offset = ((t1 - t0) + (t2 - t3)) / 2 server = client + offset
|
|
14
|
+
* rtt = (t3 - t0) - (t2 - t1) the time spent on the wire
|
|
15
|
+
*
|
|
16
|
+
* The true offset lies within `offset ± rtt / 2` of every sample, whatever the
|
|
17
|
+
* asymmetry of the path. A sample with a small round trip is therefore a tight
|
|
18
|
+
* bound, and the estimate is the one with the smallest RTT of the recent ones —
|
|
19
|
+
* a single slow exchange (a busy socket, a radio waking up) does not move it.
|
|
20
|
+
*
|
|
21
|
+
* Client times are `performance.now()`, never `Date.now()`: the page's own
|
|
22
|
+
* monotonic clock, which a user changing the system time — or NTP stepping it
|
|
23
|
+
* — does not move. What can still move is the relation between the two clocks
|
|
24
|
+
* (a suspended laptop, a server whose clock was stepped). A new sample whose
|
|
25
|
+
* bound does not overlap an older one's proves that older one stale, and it is
|
|
26
|
+
* dropped — so the estimate corrects itself on the next exchange instead of
|
|
27
|
+
* clinging to a tight but outdated sample.
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.ServerClock = exports.DEFAULT_CLOCK_MAX_AGE_MS = exports.DEFAULT_CLOCK_SAMPLES = void 0;
|
|
31
|
+
exports.clockSample = clockSample;
|
|
32
|
+
exports.DEFAULT_CLOCK_SAMPLES = 8;
|
|
33
|
+
exports.DEFAULT_CLOCK_MAX_AGE_MS = 5 * 60000;
|
|
34
|
+
/** Bounds of two samples may miss each other by this much and still agree (rounding of whole-ms server times). */
|
|
35
|
+
const AGREEMENT_SLACK_MS = 2;
|
|
36
|
+
function defaultNow() {
|
|
37
|
+
const perf = globalThis.performance;
|
|
38
|
+
return perf ? perf.now() : Date.now();
|
|
39
|
+
}
|
|
40
|
+
/** One exchange, or `null` when it cannot be one (an answer received before it was asked). */
|
|
41
|
+
function clockSample(t0, t1, t2, t3) {
|
|
42
|
+
if (![t0, t1, t2, t3].every(Number.isFinite) || t3 < t0)
|
|
43
|
+
return null;
|
|
44
|
+
// A server that says it answered before it received is taken at its first
|
|
45
|
+
// word: zero time spent there, so the whole interval is the wire's.
|
|
46
|
+
const serverMs = Math.max(0, t2 - t1);
|
|
47
|
+
const rttMs = Math.max(0, t3 - t0 - serverMs);
|
|
48
|
+
const offsetMs = (t1 - t0 + (t1 + serverMs - t3)) / 2;
|
|
49
|
+
return { t0, t1, t2: t1 + serverMs, t3, offsetMs, rttMs };
|
|
50
|
+
}
|
|
51
|
+
function agree(a, b) {
|
|
52
|
+
return Math.abs(a.offsetMs - b.offsetMs) <= (a.rttMs + b.rttMs) / 2 + AGREEMENT_SLACK_MS;
|
|
53
|
+
}
|
|
54
|
+
class ServerClock {
|
|
55
|
+
constructor(opts = {}) {
|
|
56
|
+
this.samples = [];
|
|
57
|
+
this.best = null;
|
|
58
|
+
this.total = 0;
|
|
59
|
+
this.listeners = new Set();
|
|
60
|
+
this.limit = Math.max(1, opts.samples ?? exports.DEFAULT_CLOCK_SAMPLES);
|
|
61
|
+
this.maxAgeMs = opts.maxAgeMs ?? exports.DEFAULT_CLOCK_MAX_AGE_MS;
|
|
62
|
+
this.now = opts.now ?? defaultNow;
|
|
63
|
+
}
|
|
64
|
+
/** Take one exchange into the estimate; returns it, or `null` when it was not usable. */
|
|
65
|
+
addSample(t0, t1, t2, t3) {
|
|
66
|
+
const sample = clockSample(t0, t1, t2, t3);
|
|
67
|
+
if (!sample)
|
|
68
|
+
return null;
|
|
69
|
+
this.total += 1;
|
|
70
|
+
const oldest = sample.t3 - this.maxAgeMs;
|
|
71
|
+
// Newest last. An older sample that contradicts this one belongs to a
|
|
72
|
+
// relation between the clocks that no longer holds.
|
|
73
|
+
this.samples = this.samples.filter((older) => older.t3 >= oldest && agree(older, sample));
|
|
74
|
+
this.samples.push(sample);
|
|
75
|
+
if (this.samples.length > this.limit)
|
|
76
|
+
this.samples.splice(0, this.samples.length - this.limit);
|
|
77
|
+
let best = this.samples[0];
|
|
78
|
+
for (const candidate of this.samples) {
|
|
79
|
+
// Ties go to the newer one: same bound, less drift since.
|
|
80
|
+
if (candidate.rttMs <= best.rttMs)
|
|
81
|
+
best = candidate;
|
|
82
|
+
}
|
|
83
|
+
this.best = best;
|
|
84
|
+
this.changed();
|
|
85
|
+
return sample;
|
|
86
|
+
}
|
|
87
|
+
/** Forget every sample — the estimate starts again with the next one. */
|
|
88
|
+
reset() {
|
|
89
|
+
if (this.samples.length === 0 && this.best === null)
|
|
90
|
+
return;
|
|
91
|
+
this.samples = [];
|
|
92
|
+
this.best = null;
|
|
93
|
+
this.changed();
|
|
94
|
+
}
|
|
95
|
+
get synced() {
|
|
96
|
+
return this.best !== null;
|
|
97
|
+
}
|
|
98
|
+
get offsetMs() {
|
|
99
|
+
return this.best ? this.best.offsetMs : null;
|
|
100
|
+
}
|
|
101
|
+
get rttMs() {
|
|
102
|
+
return this.best ? this.best.rttMs : null;
|
|
103
|
+
}
|
|
104
|
+
get uncertaintyMs() {
|
|
105
|
+
return this.best ? this.best.rttMs / 2 : null;
|
|
106
|
+
}
|
|
107
|
+
get sampleCount() {
|
|
108
|
+
return this.samples.length;
|
|
109
|
+
}
|
|
110
|
+
get syncedAt() {
|
|
111
|
+
const newest = this.samples[this.samples.length - 1];
|
|
112
|
+
return newest ? newest.t3 : null;
|
|
113
|
+
}
|
|
114
|
+
state() {
|
|
115
|
+
return {
|
|
116
|
+
offsetMs: this.offsetMs,
|
|
117
|
+
rttMs: this.rttMs,
|
|
118
|
+
uncertaintyMs: this.uncertaintyMs,
|
|
119
|
+
sampleCount: this.sampleCount,
|
|
120
|
+
totalSamples: this.total,
|
|
121
|
+
syncedAt: this.syncedAt,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** A client time (`performance.now()`) on the server's clock, or `null` before the first sample. */
|
|
125
|
+
toServerTime(clientTs) {
|
|
126
|
+
return this.best ? clientTs + this.best.offsetMs : null;
|
|
127
|
+
}
|
|
128
|
+
/** A server time on this page's `performance.now()` clock, or `null` before the first sample. */
|
|
129
|
+
toClientTime(serverTs) {
|
|
130
|
+
return this.best ? serverTs - this.best.offsetMs : null;
|
|
131
|
+
}
|
|
132
|
+
/** The server's clock now, as well as it is known. */
|
|
133
|
+
serverNow() {
|
|
134
|
+
return this.toServerTime(this.now());
|
|
135
|
+
}
|
|
136
|
+
/** Told after every change of the estimate. Returns the unsubscribe. */
|
|
137
|
+
subscribe(listener) {
|
|
138
|
+
this.listeners.add(listener);
|
|
139
|
+
return () => {
|
|
140
|
+
this.listeners.delete(listener);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
changed() {
|
|
144
|
+
for (const listener of [...this.listeners]) {
|
|
145
|
+
try {
|
|
146
|
+
listener();
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// A listener's failure is not the clock's.
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.ServerClock = ServerClock;
|
|
@@ -16,7 +16,15 @@
|
|
|
16
16
|
* Times are `performance.now()` — milliseconds since the page's navigation
|
|
17
17
|
* started — so the summary reads as the page's own startup: when the socket
|
|
18
18
|
* opened, when the server welcomed it, when the first data arrived.
|
|
19
|
+
*
|
|
20
|
+
* Every record carries the same moment on the server's clock as well
|
|
21
|
+
* (`serverTs`, from the client's {@link ServerClock}), with how far off that may
|
|
22
|
+
* be (`uncertaintyMs`, half the round trip of the sample it rests on). Server
|
|
23
|
+
* phases of a mutation (`meta.server`, `meta.push`) are on the server's clock
|
|
24
|
+
* already, so a click, the commit and the data that came back sit on one axis.
|
|
19
25
|
*/
|
|
26
|
+
import type { MutationTiming, TxTiming } from "../core/protocol";
|
|
27
|
+
import type { ClockState, ServerClock } from "./clock";
|
|
20
28
|
export type DevtoolsRecordType = "ws" | "subscribe" | "mutation";
|
|
21
29
|
export type DevtoolsStatus =
|
|
22
30
|
/** Waiting for the server. */
|
|
@@ -31,6 +39,8 @@ export type DevtoolsStatus =
|
|
|
31
39
|
export type DevtoolsUpdateCause = "patch" | "snapshot" | "resubscribe" | "permission-change";
|
|
32
40
|
export interface DevtoolsUpdate {
|
|
33
41
|
ts: number;
|
|
42
|
+
/** `ts` on the server's clock, when it was known. */
|
|
43
|
+
serverTs?: number;
|
|
34
44
|
bytes: number | null;
|
|
35
45
|
cause: DevtoolsUpdateCause;
|
|
36
46
|
/** Resubscribe only: time from the re-sent subscribe to its snapshot. */
|
|
@@ -51,6 +61,10 @@ export interface DevtoolsRecord {
|
|
|
51
61
|
name: string;
|
|
52
62
|
/** When it started, `performance.now()`. */
|
|
53
63
|
ts: number;
|
|
64
|
+
/** `ts` on the server's clock (epoch ms), `null` while the clock is not synced. */
|
|
65
|
+
serverTs: number | null;
|
|
66
|
+
/** How far `serverTs` may be off: ± half the round trip of the clock sample. */
|
|
67
|
+
uncertaintyMs: number | null;
|
|
54
68
|
/** Subscribe → first data, mutate → answer, connect → open… `null` while pending. */
|
|
55
69
|
durationMs: number | null;
|
|
56
70
|
/** Size on the wire in bytes (UTF-8): the first answer, or the message itself. */
|
|
@@ -87,6 +101,12 @@ export interface DevtoolsMeta {
|
|
|
87
101
|
delayMs?: number;
|
|
88
102
|
/** ws `error`: the message. */
|
|
89
103
|
message?: string;
|
|
104
|
+
/** Mutation: where it spent its time on the server, the server's clock (only from a server sending timing). */
|
|
105
|
+
server?: MutationTiming;
|
|
106
|
+
/** Mutation: first data that included it arrived, `performance.now()`. */
|
|
107
|
+
dataAt?: number;
|
|
108
|
+
/** Mutation: where that data spent its time on the server, the server's clock. */
|
|
109
|
+
push?: TxTiming;
|
|
90
110
|
}
|
|
91
111
|
/** The page's startup, as the socket saw it. All `performance.now()`, `null` = not yet. */
|
|
92
112
|
export interface DevtoolsSummary {
|
|
@@ -108,6 +128,8 @@ export interface DevtoolsSummary {
|
|
|
108
128
|
openSubscriptions: number;
|
|
109
129
|
pendingSubscriptions: number;
|
|
110
130
|
pendingMutations: number;
|
|
131
|
+
/** The client's estimate of the server's clock; `null` without one. */
|
|
132
|
+
clock: ClockState | null;
|
|
111
133
|
}
|
|
112
134
|
export interface DevtoolsOptions {
|
|
113
135
|
/** Records kept; the oldest go first. Default 500. */
|
|
@@ -127,7 +149,32 @@ export interface DevtoolsOptions {
|
|
|
127
149
|
mask?: (endpoint: string, args: unknown) => unknown;
|
|
128
150
|
/** Clock, for tests. Default `performance.now()`. */
|
|
129
151
|
now?: () => number;
|
|
152
|
+
/**
|
|
153
|
+
* The server's clock, to stamp `serverTs` with. The client passes its own
|
|
154
|
+
* ({@link NowityClient.clock}); a recorder without one has `serverTs: null`.
|
|
155
|
+
*/
|
|
156
|
+
clock?: ServerClock;
|
|
157
|
+
}
|
|
158
|
+
/** One step of a mutation, on the server's clock. */
|
|
159
|
+
export interface DevtoolsPhase {
|
|
160
|
+
name: "sent" | "received" | "started" | "committed" | "answered" | "written" | "read" | "fanOut" | "pushed" | "data";
|
|
161
|
+
/** Where it was measured: here, on the sync server, or in the database. */
|
|
162
|
+
clock: "client" | "server" | "database";
|
|
163
|
+
/** Epoch ms, the server's clock (a client time converted, `± uncertaintyMs`). */
|
|
164
|
+
serverTs: number;
|
|
165
|
+
/** From `sent`, on that axis. */
|
|
166
|
+
offsetMs: number;
|
|
167
|
+
/** Client times only: how far the conversion may be off. */
|
|
168
|
+
uncertaintyMs: number | null;
|
|
130
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* The steps of one mutation on one axis, the server's clock: sent → received →
|
|
172
|
+
* started → committed → answered, then written → read → fan-out → pushed →
|
|
173
|
+
* data. A client time is converted with the offset the record was stamped
|
|
174
|
+
* with, so a later change of the estimate does not tear one record apart.
|
|
175
|
+
* Sorted by time; empty before the clock is synced. Pure, for tests and panel.
|
|
176
|
+
*/
|
|
177
|
+
export declare function mutationPhases(record: DevtoolsRecord): DevtoolsPhase[];
|
|
131
178
|
export declare const DEFAULT_LIMIT = 500;
|
|
132
179
|
/** Updates kept per subscription; the count goes on. */
|
|
133
180
|
export declare const UPDATE_LIMIT = 50;
|
|
@@ -171,12 +218,18 @@ export declare class NowityDevtools {
|
|
|
171
218
|
/** Re-sent subscribes waiting for their snapshot: subId → when. */
|
|
172
219
|
private readonly resubscribedAt;
|
|
173
220
|
private readonly mutations;
|
|
221
|
+
/** Answered mutations whose data has not arrived yet. */
|
|
222
|
+
private readonly awaitingData;
|
|
223
|
+
private readonly clock;
|
|
224
|
+
private readonly stopClock;
|
|
174
225
|
private connection;
|
|
175
226
|
private connectAt;
|
|
176
227
|
private openedAt;
|
|
177
228
|
private closedAt;
|
|
178
229
|
private readonly startup;
|
|
179
230
|
constructor(opts?: DevtoolsOptions);
|
|
231
|
+
/** Stop following the clock. The records stay. */
|
|
232
|
+
dispose(): void;
|
|
180
233
|
/** Records, oldest first. A new array whenever {@link version} moves. */
|
|
181
234
|
get records(): readonly DevtoolsRecord[];
|
|
182
235
|
/** Moves on every change — the snapshot for `useSyncExternalStore`. */
|
|
@@ -206,13 +259,23 @@ export declare class NowityDevtools {
|
|
|
206
259
|
onUnsubscribe(subId: string): void;
|
|
207
260
|
onMutate(mutationId: number, name: string, args: unknown, bytes: number | null, optimisticMs: number | null): void;
|
|
208
261
|
onMutationResent(mutationId: number): void;
|
|
209
|
-
onMutationResult(mutationId: number, ok: boolean, error: string | undefined): void;
|
|
262
|
+
onMutationResult(mutationId: number, ok: boolean, error: string | undefined, timing?: MutationTiming): void;
|
|
263
|
+
/**
|
|
264
|
+
* Data arrived that includes every mutation up to `lastMutationId` — the
|
|
265
|
+
* first such data is where a mutation's round ends. `timing` is the
|
|
266
|
+
* server's side of it, when the server sends timing.
|
|
267
|
+
*/
|
|
268
|
+
onData(lastMutationId: number, timing: TxTiming | undefined): void;
|
|
210
269
|
/** Acknowledged by data after a reconnect, its own result lost with the old socket. */
|
|
211
270
|
onMutationSettled(mutationId: number): void;
|
|
212
271
|
onMutationLost(mutationId: number): void;
|
|
213
272
|
private mask;
|
|
214
273
|
private update;
|
|
215
274
|
private add;
|
|
275
|
+
/** `serverTs` / `uncertaintyMs` from the clock as it is now. */
|
|
276
|
+
private stamp;
|
|
277
|
+
/** Give records from before the first clock sample their server time. */
|
|
278
|
+
private backfill;
|
|
216
279
|
private changed;
|
|
217
280
|
}
|
|
218
281
|
//# sourceMappingURL=devtools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../../src/client/devtools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../../src/client/devtools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGvD,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,WAAW,GAAG,UAAU,CAAC;AAEjE,MAAM,MAAM,cAAc;AACtB,8BAA8B;AAC5B,SAAS,GACT,IAAI;AACN,uEAAuE;GACrE,UAAU,GACV,OAAO;AACT,oBAAoB;GAClB,QAAQ;AACV,0FAA0F;GACxF,MAAM,CAAC;AAEb,+DAA+D;AAC/D,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,mBAAmB,CAAC;AAE7F,MAAM,WAAW,cAAc;IA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