forked from coracle/flotilla
Tweak signer error
This commit is contained in:
@@ -15,14 +15,13 @@
|
|||||||
const pending = $derived($signerLog.filter(x => !x.finished_at))
|
const pending = $derived($signerLog.filter(x => !x.finished_at))
|
||||||
const failure = $derived(finished.filter(spec({ok: false})))
|
const failure = $derived(finished.filter(spec({ok: false})))
|
||||||
const success = $derived(finished.filter(spec({ok: true})))
|
const success = $derived(finished.filter(spec({ok: true})))
|
||||||
const recent = $derived($signerLog.filter(x => x.started_at < Date.now() - 5000).slice(-10))
|
const cutoff = $derived(Date.now() - 10_000)
|
||||||
const recentFinished = $derived(recent.filter(x => x.finished_at))
|
const recentCompleted = $derived($signerLog.filter(x => x.finished_at && x.finished_at > cutoff))
|
||||||
const recentPending = $derived(recent.filter(x => !x.finished_at))
|
const recentAvg = $derived(avg(recentCompleted.map(x => x.finished_at! - x.started_at)))
|
||||||
const recentAvg = $derived(avg(recentFinished.map(x => x.finished_at! - x.started_at)))
|
const recentFailure = $derived(recentCompleted.filter(x => !x.ok))
|
||||||
const recentFailure = $derived(recentFinished.filter(x => !x.ok))
|
const recentSuccess = $derived(recentCompleted.filter(x => x.ok))
|
||||||
const recentSuccess = $derived(recentFinished.filter(x => x.ok))
|
|
||||||
const isDisconnected = $derived(
|
const isDisconnected = $derived(
|
||||||
recent.length > 0 && recentFailure.length + recentPending.length === recent.length,
|
recentCompleted.length > 0 && recentFailure.length === recentCompleted.length,
|
||||||
)
|
)
|
||||||
|
|
||||||
const logout = () => pushModal(LogOut)
|
const logout = () => pushModal(LogOut)
|
||||||
@@ -38,7 +37,7 @@
|
|||||||
<Icon icon={CloseCircle} class="text-error" size={4} /> Disconnected
|
<Icon icon={CloseCircle} class="text-error" size={4} /> Disconnected
|
||||||
{:else if recentFailure.length > 3}
|
{:else if recentFailure.length > 3}
|
||||||
<Icon icon={Danger} class="text-warning" size={4} /> Partial Failure
|
<Icon icon={Danger} class="text-warning" size={4} /> Partial Failure
|
||||||
{:else if recentAvg > 1000 || recentPending.length > 3}
|
{:else if recentAvg > 1000 || pending.length > 10}
|
||||||
<Icon icon={ClockCircle} class="text-warning" size={4} /> Slow connection
|
<Icon icon={ClockCircle} class="text-warning" size={4} /> Slow connection
|
||||||
{:else if recentSuccess.length === 0 && recentFailure.length > 0}
|
{:else if recentSuccess.length === 0 && recentFailure.length > 0}
|
||||||
<Icon icon={Danger} class="text-warning" size={4} /> Partial Failure
|
<Icon icon={Danger} class="text-warning" size={4} /> Partial Failure
|
||||||
|
|||||||
@@ -157,15 +157,20 @@
|
|||||||
// Listen for signer errors, report to user via toast
|
// Listen for signer errors, report to user via toast
|
||||||
unsubscribers.push(
|
unsubscribers.push(
|
||||||
throttled(10_000, signerLog).subscribe($log => {
|
throttled(10_000, signerLog).subscribe($log => {
|
||||||
const cutoff = Date.now() - 3_000
|
if ($toast) return
|
||||||
const recent = $log.filter(x => x.started_at < cutoff).slice(-10)
|
|
||||||
const ok = recent.filter(x => x.ok)
|
|
||||||
|
|
||||||
if (!$toast && recent.length > 5 && ok.length === 0) {
|
const longCutoff = Date.now() - 30_000
|
||||||
|
const shortCutoff = Date.now() - 10_000
|
||||||
|
const pending = $log.filter(x => !x.finished_at && x.started_at < longCutoff)
|
||||||
|
const completed = $log.filter(x => x.finished_at && x.finished_at > shortCutoff)
|
||||||
|
const showPendingError = pending.length > 10
|
||||||
|
const showCompletedError = completed.length > 5 && completed.filter(x => x.ok).length === 0
|
||||||
|
|
||||||
|
if (showPendingError || showCompletedError) {
|
||||||
pushToast({
|
pushToast({
|
||||||
theme: "error",
|
theme: "error",
|
||||||
timeout: 60_000,
|
timeout: 60_000,
|
||||||
message: "Your signer appears to be unresponsive.",
|
message: "Your signer isn't responding.",
|
||||||
action: {
|
action: {
|
||||||
message: "Details",
|
message: "Details",
|
||||||
onclick: () => goto("/settings/profile"),
|
onclick: () => goto("/settings/profile"),
|
||||||
|
|||||||
Reference in New Issue
Block a user