@gearbox-protocol/sdk 9.1.6 → 9.1.7

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.
@@ -34,6 +34,7 @@ class RevolverTransport {
34
34
  #index = 0;
35
35
  #config;
36
36
  #rotating = false;
37
+ #requests = /* @__PURE__ */ new WeakMap();
37
38
  overrides;
38
39
  /**
39
40
  * Create a new RevolverTransport
@@ -99,16 +100,25 @@ class RevolverTransport {
99
100
  }
100
101
  do {
101
102
  try {
103
+ this.#requests.set(r, this.currentTransportName);
102
104
  const resp = await this.#transport({ ...this.overrides }).request(r);
105
+ this.#requests.delete(r);
103
106
  return resp;
104
107
  } catch (e) {
105
108
  if (e instanceof import_viem.RpcError || e instanceof import_viem.HttpRequestError) {
106
- await this.rotate(e);
109
+ const reqTransport = this.#requests.get(r);
110
+ if (reqTransport === this.currentTransportName) {
111
+ await this.rotate(e);
112
+ } else {
113
+ this.#logger?.debug("request made with old transport, try again");
114
+ }
107
115
  } else {
116
+ this.#requests.delete(r);
108
117
  throw e;
109
118
  }
110
119
  }
111
120
  } while (this.#hasAvailableTransports);
121
+ this.#requests.delete(r);
112
122
  throw new NoAvailableTransportsError();
113
123
  };
114
124
  get config() {
@@ -17,6 +17,7 @@ class RevolverTransport {
17
17
  #index = 0;
18
18
  #config;
19
19
  #rotating = false;
20
+ #requests = /* @__PURE__ */ new WeakMap();
20
21
  overrides;
21
22
  /**
22
23
  * Create a new RevolverTransport
@@ -82,16 +83,25 @@ class RevolverTransport {
82
83
  }
83
84
  do {
84
85
  try {
86
+ this.#requests.set(r, this.currentTransportName);
85
87
  const resp = await this.#transport({ ...this.overrides }).request(r);
88
+ this.#requests.delete(r);
86
89
  return resp;
87
90
  } catch (e) {
88
91
  if (e instanceof RpcError || e instanceof HttpRequestError) {
89
- await this.rotate(e);
92
+ const reqTransport = this.#requests.get(r);
93
+ if (reqTransport === this.currentTransportName) {
94
+ await this.rotate(e);
95
+ } else {
96
+ this.#logger?.debug("request made with old transport, try again");
97
+ }
90
98
  } else {
99
+ this.#requests.delete(r);
91
100
  throw e;
92
101
  }
93
102
  }
94
103
  } while (this.#hasAvailableTransports);
104
+ this.#requests.delete(r);
95
105
  throw new NoAvailableTransportsError();
96
106
  };
97
107
  get config() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "9.1.6",
3
+ "version": "9.1.7",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",