Skip to content

Commit de69df7

Browse files
committed
temp: sub second WS subscribe time
1 parent cd88758 commit de69df7

File tree

4 files changed

+415
-145
lines changed

4 files changed

+415
-145
lines changed

sdk/src/accounts/webSocketAccountSubscriberV2.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ export class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
9191
this.rpcSubscriptions = rpcSubscriptions;
9292
}
9393

94-
private async handleNotificationLoop(subscription: AsyncIterable<any>) {
94+
private async handleNotificationLoop(subscriptionPromise: Promise<AsyncIterable<any>>) {
95+
const subscription = await subscriptionPromise;
9596
for await (const notification of subscription) {
9697
// If we're currently polling and receive a WebSocket event, stop polling
9798
if (this.pollingTimeoutId) {
@@ -143,7 +144,7 @@ export class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
143144
// Subscribe to account changes using gill's rpcSubscriptions
144145
const pubkey = this.accountPublicKey.toBase58();
145146
if (isAddress(pubkey)) {
146-
const subscription = await this.rpcSubscriptions
147+
const subscriptionPromise = this.rpcSubscriptions
147148
.accountNotifications(pubkey, {
148149
commitment: this.commitment,
149150
encoding: 'base64',
@@ -152,8 +153,8 @@ export class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
152153
abortSignal: abortController.signal,
153154
});
154155

155-
// Start notification loop without awaiting
156-
this.handleNotificationLoop(subscription);
156+
// Start notification loop with the subscription promise
157+
this.handleNotificationLoop(subscriptionPromise);
157158
}
158159
}
159160

0 commit comments

Comments
 (0)