Various homeserver state FST and queue fixes #101
1 changed files with 6 additions and 3 deletions
matrix: queue d2m events while checking the homeserver
During a "check assume offline" at startup, `isRealTime()` is false, so incoming Discord events get queued, but `queuePacket()` asserted that we were offline or recovering. The updated assertion implicitly adds `checking` to the list of valid states, allowing packets to be queued in this state.
commit
a723c1c1a6
|
|
@ -42,7 +42,9 @@ const homeserverStatus = sync.remember(() => new class HomeserverStatus {
|
|||
this.checkingWhileOnline = event === "check assume online"
|
||||
const pingResult = await api.ping().catch(e => ({ok: false}))
|
||||
this.lastCheck = Date.now()
|
||||
if (pingResult.ok) {
|
||||
if (pingResult.ok && !this.queue.isEmpty()) {
|
||||
this.sm.doTransition("check ok with queue")
|
||||
} else if (pingResult.ok) {
|
||||
this.sm.doTransition("check ok")
|
||||
} else {
|
||||
this.sm.doTransition("check fail")
|
||||
|
|
@ -99,6 +101,7 @@ const homeserverStatus = sync.remember(() => new class HomeserverStatus {
|
|||
.defineTransition("online", "check assume online", "checking")
|
||||
.defineTransition("online", "check assume offline", "checking")
|
||||
.defineTransition("checking", "check ok", "online")
|
||||
.defineTransition("checking", "check ok with queue", "recovering")
|
||||
.defineTransition("checking", "check fail", "offline")
|
||||
|
||||
this.sm.on("enter", st => debugHomeserverStatus(`homeserver status: ${st}`))
|
||||
|
|
@ -137,10 +140,10 @@ const homeserverStatus = sync.remember(() => new class HomeserverStatus {
|
|||
}
|
||||
|
||||
/**
|
||||
* When offline or recovering, call this for incoming packets to queue them to be sent in order later.
|
||||
* When not real time, call this for incoming packets to queue them to be sent in order later.
|
||||
*/
|
||||
queuePacket(sourceAndPacket) {
|
||||
assert(["offline", "recovering"].includes(this.sm.currentStateName))
|
||||
assert(!this.isRealTime())
|
||||
this.queue.push(sourceAndPacket)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue