mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-12 22:46:11 +03:00
interface: do not leak on reconnect
This commit is contained in:
parent
d581d1f61d
commit
f8d56a86c4
@ -14,13 +14,7 @@ export const bootstrapApi = async () => {
|
||||
|
||||
airlock.onError = (e) => {
|
||||
(async () => {
|
||||
try {
|
||||
useLocalState.setState({ subscription: 'reconnecting' });
|
||||
airlock.reset();
|
||||
await bootstrapApi();
|
||||
} catch (e) {
|
||||
useLocalState.setState({ subscription: 'disconnected' });
|
||||
}
|
||||
useLocalState.setState({ subscription: 'disconnected' });
|
||||
})();
|
||||
};
|
||||
|
||||
|
@ -52,6 +52,11 @@ export class Urbit {
|
||||
*/
|
||||
private outstandingSubscriptions: Map<number, SubscriptionRequestInterface> = new Map();
|
||||
|
||||
/**
|
||||
* Our abort controller, used to close the connection
|
||||
*/
|
||||
private abort = new AbortController();
|
||||
|
||||
/**
|
||||
* Ship can be set, in which case we can do some magic stuff like send chats
|
||||
*/
|
||||
@ -88,7 +93,8 @@ export class Urbit {
|
||||
return {
|
||||
credentials: 'include',
|
||||
accept: '*',
|
||||
headers
|
||||
headers,
|
||||
signal: this.abort
|
||||
};
|
||||
}
|
||||
|
||||
@ -258,6 +264,9 @@ export class Urbit {
|
||||
*
|
||||
*/
|
||||
reset() {
|
||||
this.delete();
|
||||
this.abort.abort();
|
||||
this.abort = new AbortController();
|
||||
this.uid = `${Math.floor(Date.now() / 1000)}-${hexString(6)}`;
|
||||
this.lastEventId = 0;
|
||||
this.lastAcknowledgedEventId = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user