mirror of
https://github.com/urbit/shrub.git
synced 2024-12-22 18:31:44 +03:00
@urbit/http-api: enable subscription resume
This commit is contained in:
parent
3cdf3a0762
commit
ef4cdca187
@ -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');
|
||||
|
||||
},
|
||||
});
|
||||
})
|
||||
|
@ -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 {}
|
||||
|
Loading…
Reference in New Issue
Block a user