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 { 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');
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -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 {}
|
||||||
|
Loading…
Reference in New Issue
Block a user