@@ -91,7 +91,8 @@ export class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
91
91
this . rpcSubscriptions = rpcSubscriptions ;
92
92
}
93
93
94
- private async handleNotificationLoop ( subscription : AsyncIterable < any > ) {
94
+ private async handleNotificationLoop ( subscriptionPromise : Promise < AsyncIterable < any > > ) {
95
+ const subscription = await subscriptionPromise ;
95
96
for await ( const notification of subscription ) {
96
97
// If we're currently polling and receive a WebSocket event, stop polling
97
98
if ( this . pollingTimeoutId ) {
@@ -143,7 +144,7 @@ export class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
143
144
// Subscribe to account changes using gill's rpcSubscriptions
144
145
const pubkey = this . accountPublicKey . toBase58 ( ) ;
145
146
if ( isAddress ( pubkey ) ) {
146
- const subscription = await this . rpcSubscriptions
147
+ const subscriptionPromise = this . rpcSubscriptions
147
148
. accountNotifications ( pubkey , {
148
149
commitment : this . commitment ,
149
150
encoding : 'base64' ,
@@ -152,8 +153,8 @@ export class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
152
153
abortSignal : abortController . signal ,
153
154
} ) ;
154
155
155
- // Start notification loop without awaiting
156
- this . handleNotificationLoop ( subscription ) ;
156
+ // Start notification loop with the subscription promise
157
+ this . handleNotificationLoop ( subscriptionPromise ) ;
157
158
}
158
159
}
159
160
0 commit comments