From af9f67256868fca62d8ff79a4a4a2cf837c31869 Mon Sep 17 00:00:00 2001 From: wphan Date: Wed, 30 Jul 2025 08:35:14 -0700 Subject: [PATCH] sdk: revert grpc account subscribers to v2.126.0-beta.0 --- sdk/src/accounts/grpcAccountSubscriber.ts | 30 ++----------------- .../accounts/grpcProgramAccountSubscriber.ts | 30 ++----------------- 2 files changed, 4 insertions(+), 56 deletions(-) diff --git a/sdk/src/accounts/grpcAccountSubscriber.ts b/sdk/src/accounts/grpcAccountSubscriber.ts index 1ef65cd17c..be141c3746 100644 --- a/sdk/src/accounts/grpcAccountSubscriber.ts +++ b/sdk/src/accounts/grpcAccountSubscriber.ts @@ -18,7 +18,6 @@ export class grpcAccountSubscriber extends WebSocketAccountSubscriber { private stream: ClientDuplexStream; private commitmentLevel: CommitmentLevel; public listenerId?: number; - private enableReconnect: boolean; private constructor( client: Client, @@ -27,13 +26,11 @@ export class grpcAccountSubscriber extends WebSocketAccountSubscriber { program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, - resubOpts?: ResubOpts, - enableReconnect = false + resubOpts?: ResubOpts ) { super(accountName, program, accountPublicKey, decodeBuffer, resubOpts); this.client = client; this.commitmentLevel = commitmentLevel; - this.enableReconnect = enableReconnect; } public static async create( @@ -60,8 +57,7 @@ export class grpcAccountSubscriber extends WebSocketAccountSubscriber { program, accountPublicKey, decodeBuffer, - resubOpts, - grpcConfigs.enableReconnect + resubOpts ); } @@ -95,26 +91,6 @@ export class grpcAccountSubscriber extends WebSocketAccountSubscriber { entry: {}, transactionsStatus: {}, }; - - if (this.enableReconnect) { - this.stream.on('error', (error) => { - // @ts-ignore - if (error.code === 1) { - // expected: 1 CANCELLED: Cancelled on client - console.error( - 'GRPC (grpcAccountSubscriber) Cancelled on client caught:', - error - ); - return; - } else { - console.error( - 'GRPC (grpcAccountSubscriber) unexpected error caught:', - error - ); - } - }); - } - this.stream.on('data', (chunk: SubscribeUpdate) => { if (!chunk.account) { return; @@ -196,8 +172,6 @@ export class grpcAccountSubscriber extends WebSocketAccountSubscriber { reject(err); } }); - this.stream.cancel(); - this.stream.destroy(); }).catch((reason) => { console.error(reason); throw reason; diff --git a/sdk/src/accounts/grpcProgramAccountSubscriber.ts b/sdk/src/accounts/grpcProgramAccountSubscriber.ts index d669b508e9..f575c64229 100644 --- a/sdk/src/accounts/grpcProgramAccountSubscriber.ts +++ b/sdk/src/accounts/grpcProgramAccountSubscriber.ts @@ -20,7 +20,6 @@ export class grpcProgramAccountSubscriber< private stream: ClientDuplexStream; private commitmentLevel: CommitmentLevel; public listenerId?: number; - private enableReconnect: boolean; private constructor( client: Client, @@ -32,8 +31,7 @@ export class grpcProgramAccountSubscriber< options: { filters: MemcmpFilter[] } = { filters: [], }, - resubOpts?: ResubOpts, - enableReconnect = false + resubOpts?: ResubOpts ) { super( subscriptionName, @@ -45,7 +43,6 @@ export class grpcProgramAccountSubscriber< ); this.client = client; this.commitmentLevel = commitmentLevel; - this.enableReconnect = enableReconnect; } public static async create( @@ -76,8 +73,7 @@ export class grpcProgramAccountSubscriber< program, decodeBufferFn, options, - resubOpts, - grpcConfigs.enableReconnect + resubOpts ); } @@ -123,26 +119,6 @@ export class grpcProgramAccountSubscriber< entry: {}, transactionsStatus: {}, }; - - if (this.enableReconnect) { - this.stream.on('error', (error) => { - // @ts-ignore - if (error.code === 1) { - // expected: 1 CANCELLED: Cancelled on client - console.error( - 'GRPC (grpcProgramAccountSubscriber) Cancelled on client caught:', - error - ); - return; - } else { - console.error( - 'GRPC (grpcProgramAccountSubscriber) unexpected error caught:', - error - ); - } - }); - } - this.stream.on('data', (chunk: SubscribeUpdate) => { if (!chunk.account) { return; @@ -230,8 +206,6 @@ export class grpcProgramAccountSubscriber< reject(err); } }); - this.stream.cancel(); - this.stream.destroy(); }).catch((reason) => { console.error(reason); throw reason;