Skip to content

Commit

Permalink
fix(suite): disable Solana websockets and account subscriptions
Browse files Browse the repository at this point in the history
It seems that there are some issues with the websockets connection which are hard to identify and find. They seem to be happening quite randomly or in very specific cases i.e. they can't be reproduced and thus are very hard to fix. For now we decided to disable the Solana SDK websockets connection and thus we also disabled account subscriptions (which were supposedly causing the issues).

(cherry picked from commit 3c6f925)
  • Loading branch information
gabrielKerekes authored and komret committed Dec 12, 2023
1 parent ffe03a7 commit 6de97f0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/blockchain-link/src/workers/solana/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ const unsubscribeBlock = ({ state }: Context) => {
state.removeSubscription('block');
};

// @ts-expect-error
const subscribeAccounts = async (
{ connect, state, post }: Context,
accounts: SubscriptionAccountInfo[],
Expand Down Expand Up @@ -335,6 +336,7 @@ const subscribeAccounts = async (
return { subscribed: true };
};

// @ts-expect-error
const unsubscribeAccounts = async (
{ state, connect }: Context,
accounts: SubscriptionAccountInfo[] | undefined = [],
Expand All @@ -354,7 +356,8 @@ const subscribe = (request: Request<MessageTypes.Subscribe>) => {
subscribeBlock(request);
break;
case 'accounts':
subscribeAccounts(request, request.payload.accounts);
// accounts subscription is currently disabled due to it possibly causing crashes
// subscribeAccounts(request, request.payload.accounts);
break;
default:
throw new CustomError('worker_unknown_request', `+${request.type}`);
Expand All @@ -371,7 +374,8 @@ const unsubscribe = (request: Request<MessageTypes.Unsubscribe>) => {
unsubscribeBlock(request);
break;
case 'accounts': {
unsubscribeAccounts(request, request.payload.accounts);
// accounts subscription is currently disabled due to it possibly causing crashes
// unsubscribeAccounts(request, request.payload.accounts);
break;
}
default:
Expand Down Expand Up @@ -408,7 +412,8 @@ class SolanaWorker extends BaseWorker<SolanaAPI> {
}

tryConnect(url: string): Promise<SolanaAPI> {
const api = new Connection(url, { wsEndpoint: url.replace('https', 'wss') });
// websocket connection is currently disabled due to it possibly causing crashes
const api = new Connection(url /* , { wsEndpoint: url.replace('https', 'wss') } */);
this.post({ id: -1, type: RESPONSES.CONNECTED });
return Promise.resolve(api);
}
Expand Down Expand Up @@ -437,9 +442,10 @@ class SolanaWorker extends BaseWorker<SolanaAPI> {
return;
}

this.state.accounts.forEach(
a => a.subscriptionId && this.api?.removeAccountChangeListener(a.subscriptionId),
);
// accounts subscription is currently disabled due to it possibly causing crashes
// this.state.accounts.forEach(
// a => a.subscriptionId && this.api?.removeAccountChangeListener(a.subscriptionId),
// );

if (this.state.getSubscription('block')) {
const interval = this.state.getSubscription('block') as NodeJS.Timer;
Expand Down

0 comments on commit 6de97f0

Please sign in to comment.