@urbit/api: do not reconnect if there is a FatalError

This commit is contained in:
Liam Fitzgerald 2022-03-31 14:52:18 -06:00
parent 3496a8e8bf
commit 66536bebcd

View File

@ -14,6 +14,7 @@ import {
SSEOptions,
PokeHandlers,
Message,
FatalError,
} from './types';
import { hexString } from './utils';
@ -291,7 +292,7 @@ export class Urbit {
},
onerror: (error) => {
console.warn(error);
if (this.errorCount++ < 4) {
if (!(error instanceof FatalError) && this.errorCount++ < 4) {
this.onRetry && this.onRetry();
return Math.pow(2, this.errorCount - 1) * 750;
}
@ -311,6 +312,9 @@ export class Urbit {
*
*/
reset() {
if(this.verbose) {
console.log('resetting');
}
this.delete();
this.abort.abort();
this.abort = new AbortController();