mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-03 14:37:05 +03:00
webdojo: attempt reconnecting only after success
Instead of always endlessly trying even if the endpoint was never acknowledged.
This commit is contained in:
parent
b12f89228b
commit
f9e6c9f913
@ -19,9 +19,11 @@ export default class Subscription {
|
||||
|
||||
setupSlog() {
|
||||
const slog = new EventSource('/~/slog', { withCredentials: true });
|
||||
let available = false;
|
||||
|
||||
slog.onopen = e => {
|
||||
console.log('slog: opened stream');
|
||||
available = true;
|
||||
}
|
||||
|
||||
slog.onmessage = e => {
|
||||
@ -30,11 +32,13 @@ export default class Subscription {
|
||||
|
||||
slog.onerror = e => {
|
||||
console.error('slog: eventsource error:', e);
|
||||
window.setTimeout(() => {
|
||||
if (slog.readyState !== EventSource.CLOSED) return;
|
||||
console.log('slog: reconnecting...');
|
||||
this.setupSlog();
|
||||
}, 10000);
|
||||
if (available) {
|
||||
window.setTimeout(() => {
|
||||
if (slog.readyState !== EventSource.CLOSED) return;
|
||||
console.log('slog: reconnecting...');
|
||||
this.setupSlog();
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user