Fix issues found in review of host pairing

- Saves of a datastore run one at a time, and changes made while saving
  are saved by the next save. Overlapping saves from approving and
  revoking hosts could write an older snapshot after a newer one.
- Map subscribers fetch everything again when a new session starts, as
  the controller only sends values that exist. A host revoked while a
  browser was disconnected stayed in its list.
- The host token check accepts the same pre-rename tokens as the
  WebSocket, so upgrading a host with such a token does not make it ask
  to join again.
This commit is contained in:
Danielv123 committed 2026-10-30 21:49:53 +01:00
1 parent 2cf7c66187
commit 1ed46dff9c
8 files changed
+121 -30

No files matched your search

+10
View File
@@ -725,6 +725,16 @@ export class MapSubscriber<
/** Current value of the subscribed resource */
values = new Map<K, V>();
override handleConnectionEvent(event: "connect" | "drop" | "resume" | "close") {
if (event === "connect") {
// A new session is only sent values that exist, not ones removed while disconnected,
// so everything is fetched again.
this.values.clear();
this.lastUpdatedMs = -1;
}
super.handleConnectionEvent(event);
}
protected override getLastUpdatedTimeMs(event: E) {
let maxTime = this.lastUpdatedMs;
for (const update of event.updates) {