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

View File

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