@drift-labs/sdk 2.130.0-beta.2 → 2.130.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.130.0-beta.2
1
+ 2.130.0-beta.3
@@ -20,8 +20,11 @@ class WebSocketAccountSubscriber {
20
20
  commitment !== null && commitment !== void 0 ? commitment : this.program.provider.opts.commitment;
21
21
  }
22
22
  async subscribe(onChange) {
23
- var _a;
23
+ var _a, _b;
24
24
  if (this.listenerId != null || this.isUnsubscribing) {
25
+ if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
26
+ console.log(`[${this.logAccountName}] Subscribe returning early - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
27
+ }
25
28
  return;
26
29
  }
27
30
  this.onChange = onChange;
@@ -40,7 +43,7 @@ class WebSocketAccountSubscriber {
40
43
  this.handleRpcResponse(context, accountInfo);
41
44
  }
42
45
  }, this.commitment);
43
- if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) {
46
+ if ((_b = this.resubOpts) === null || _b === void 0 ? void 0 : _b.resubTimeoutMs) {
44
47
  this.receivingData = true;
45
48
  this.setTimeout();
46
49
  }
@@ -61,18 +64,29 @@ class WebSocketAccountSubscriber {
61
64
  throw new Error('onChange callback function must be set');
62
65
  }
63
66
  this.timeoutId = setTimeout(async () => {
64
- var _a;
67
+ var _a, _b, _c, _d;
65
68
  if (this.isUnsubscribing) {
66
69
  // If we are in the process of unsubscribing, do not attempt to resubscribe
70
+ if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
71
+ console.log(`[${this.logAccountName}] Timeout fired but isUnsubscribing=true, skipping resubscribe`);
72
+ }
67
73
  return;
68
74
  }
69
75
  if (this.receivingData) {
70
- if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
71
- console.log(`No ws data from ${this.logAccountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing`);
76
+ if ((_b = this.resubOpts) === null || _b === void 0 ? void 0 : _b.logResubMessages) {
77
+ console.log(`No ws data from ${this.logAccountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
72
78
  }
73
79
  await this.unsubscribe(true);
74
80
  this.receivingData = false;
75
81
  await this.subscribe(this.onChange);
82
+ if ((_c = this.resubOpts) === null || _c === void 0 ? void 0 : _c.logResubMessages) {
83
+ console.log(`[${this.logAccountName}] Resubscribe completed - receivingData=${this.receivingData}, listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
84
+ }
85
+ }
86
+ else {
87
+ if ((_d = this.resubOpts) === null || _d === void 0 ? void 0 : _d.logResubMessages) {
88
+ console.log(`[${this.logAccountName}] Timeout fired but receivingData=false, skipping resubscribe`);
89
+ }
76
90
  }
77
91
  }, (_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs);
78
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webSocketAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/webSocketAccountSubscriber.ts"],"names":[],"mappings":";;AAAA,OAAO,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAkB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI9E,qBAAa,0BAA0B,CAAC,CAAC,CAAE,YAAW,iBAAiB,CAAC,CAAC,CAAC;IACzE,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,OA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AK,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI;IA0C5E,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC;IAW/B,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB3C"}
@@ -20,8 +20,11 @@ class WebSocketAccountSubscriber {
20
20
  commitment !== null && commitment !== void 0 ? commitment : this.program.provider.opts.commitment;
21
21
  }
22
22
  async subscribe(onChange) {
23
- var _a;
23
+ var _a, _b;
24
24
  if (this.listenerId != null || this.isUnsubscribing) {
25
+ if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
26
+ console.log(`[${this.logAccountName}] Subscribe returning early - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
27
+ }
25
28
  return;
26
29
  }
27
30
  this.onChange = onChange;
@@ -40,7 +43,7 @@ class WebSocketAccountSubscriber {
40
43
  this.handleRpcResponse(context, accountInfo);
41
44
  }
42
45
  }, this.commitment);
43
- if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) {
46
+ if ((_b = this.resubOpts) === null || _b === void 0 ? void 0 : _b.resubTimeoutMs) {
44
47
  this.receivingData = true;
45
48
  this.setTimeout();
46
49
  }
@@ -61,18 +64,29 @@ class WebSocketAccountSubscriber {
61
64
  throw new Error('onChange callback function must be set');
62
65
  }
63
66
  this.timeoutId = setTimeout(async () => {
64
- var _a;
67
+ var _a, _b, _c, _d;
65
68
  if (this.isUnsubscribing) {
66
69
  // If we are in the process of unsubscribing, do not attempt to resubscribe
70
+ if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
71
+ console.log(`[${this.logAccountName}] Timeout fired but isUnsubscribing=true, skipping resubscribe`);
72
+ }
67
73
  return;
68
74
  }
69
75
  if (this.receivingData) {
70
- if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
71
- console.log(`No ws data from ${this.logAccountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing`);
76
+ if ((_b = this.resubOpts) === null || _b === void 0 ? void 0 : _b.logResubMessages) {
77
+ console.log(`No ws data from ${this.logAccountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
72
78
  }
73
79
  await this.unsubscribe(true);
74
80
  this.receivingData = false;
75
81
  await this.subscribe(this.onChange);
82
+ if ((_c = this.resubOpts) === null || _c === void 0 ? void 0 : _c.logResubMessages) {
83
+ console.log(`[${this.logAccountName}] Resubscribe completed - receivingData=${this.receivingData}, listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
84
+ }
85
+ }
86
+ else {
87
+ if ((_d = this.resubOpts) === null || _d === void 0 ? void 0 : _d.logResubMessages) {
88
+ console.log(`[${this.logAccountName}] Timeout fired but receivingData=false, skipping resubscribe`);
89
+ }
76
90
  }
77
91
  }, (_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs);
78
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.130.0-beta.2",
3
+ "version": "2.130.0-beta.3",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -55,6 +55,11 @@ export class WebSocketAccountSubscriber<T> implements AccountSubscriber<T> {
55
55
 
56
56
  async subscribe(onChange: (data: T) => void): Promise<void> {
57
57
  if (this.listenerId != null || this.isUnsubscribing) {
58
+ if (this.resubOpts?.logResubMessages) {
59
+ console.log(
60
+ `[${this.logAccountName}] Subscribe returning early - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`
61
+ );
62
+ }
58
63
  return;
59
64
  }
60
65
 
@@ -104,18 +109,34 @@ export class WebSocketAccountSubscriber<T> implements AccountSubscriber<T> {
104
109
  async () => {
105
110
  if (this.isUnsubscribing) {
106
111
  // If we are in the process of unsubscribing, do not attempt to resubscribe
112
+ if (this.resubOpts?.logResubMessages) {
113
+ console.log(
114
+ `[${this.logAccountName}] Timeout fired but isUnsubscribing=true, skipping resubscribe`
115
+ );
116
+ }
107
117
  return;
108
118
  }
109
119
 
110
120
  if (this.receivingData) {
111
121
  if (this.resubOpts?.logResubMessages) {
112
122
  console.log(
113
- `No ws data from ${this.logAccountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing`
123
+ `No ws data from ${this.logAccountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`
114
124
  );
115
125
  }
116
126
  await this.unsubscribe(true);
117
127
  this.receivingData = false;
118
128
  await this.subscribe(this.onChange);
129
+ if (this.resubOpts?.logResubMessages) {
130
+ console.log(
131
+ `[${this.logAccountName}] Resubscribe completed - receivingData=${this.receivingData}, listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`
132
+ );
133
+ }
134
+ } else {
135
+ if (this.resubOpts?.logResubMessages) {
136
+ console.log(
137
+ `[${this.logAccountName}] Timeout fired but receivingData=false, skipping resubscribe`
138
+ );
139
+ }
119
140
  }
120
141
  },
121
142
  this.resubOpts?.resubTimeoutMs