@urbit/http-api: enable subscription resume

This commit is contained in:
Liam Fitzgerald 2021-07-22 12:50:39 +10:00
parent 3cdf3a0762
commit ef4cdca187
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 6 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import { isBrowser, isNode } from 'browser-or-node';
import { fetchEventSource, EventSourceMessage, EventStreamContentType } from '@microsoft/fetch-event-source';
import { Action, Scry, Thread, AuthenticationInterface, SubscriptionInterface, CustomEventHandler, PokeInterface, SubscriptionRequestInterface, headers, SSEOptions, PokeHandlers, Message } from './types';
import { Action, Scry, Thread, AuthenticationInterface, SubscriptionInterface, CustomEventHandler, PokeInterface, SubscriptionRequestInterface, headers, SSEOptions, PokeHandlers, Message, FatalError } from './types';
import { uncamelize, hexString } from './utils';
/**
@ -197,7 +197,6 @@ export class Urbit {
resolve();
return; // everything's good
} else {
this.onError && this.onError(new Error('bad response'));
reject();
}
},
@ -251,9 +250,7 @@ export class Urbit {
}
},
onerror: (error) => {
// Channel resume currently broken in eyre
if(false && this.errorCount++ < 5) {
console.log(this.errorCount);
if(!(error instanceof FatalError) && this.errorCount++ < 5) {
this.onRetry && this.onRetry();
return Math.pow(2, this.errorCount - 1) * 750;
}
@ -262,7 +259,6 @@ export class Urbit {
},
onclose: () => {
throw Error('Ship unexpectedly closed the connection');
},
});
})

View File

@ -194,3 +194,7 @@ export interface Message extends Record<string, any> {
action: Action;
id?: number;
}
export class ResumableError extends Error {}
export class FatalError extends Error {}