@hiveio/dhive 1.3.4 → 1.3.5
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/dist/dhive.js +2 -2
- package/dist/dhive.js.gz +0 -0
- package/dist/dhive.js.map +1 -1
- package/lib/utils.js +16 -13
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/utils.js
CHANGED
|
@@ -187,21 +187,24 @@ function retryingFetch(currentAddress, allAddresses, opts, timeout, failoverThre
|
|
|
187
187
|
}
|
|
188
188
|
const response = yield cross_fetch_1.default(node, opts);
|
|
189
189
|
if (!response.ok) {
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// JSON parse failed, fall through to error handling
|
|
190
|
+
// Some Hive nodes return non-200 HTTP status (500, 502, 503, 429, etc.)
|
|
191
|
+
// but still include a valid JSON-RPC response in the body.
|
|
192
|
+
// This happens when a node is overloaded — it processes the transaction
|
|
193
|
+
// but returns an error HTTP status. For broadcasts, ignoring the body
|
|
194
|
+
// would cause the caller to think it failed, leading to double-posts.
|
|
195
|
+
try {
|
|
196
|
+
const resJson = yield response.json();
|
|
197
|
+
if (resJson.jsonrpc === '2.0') {
|
|
198
|
+
if (healthTracker && api)
|
|
199
|
+
healthTracker.recordSuccess(node, api);
|
|
200
|
+
return { response: resJson, currentAddress: node };
|
|
202
201
|
}
|
|
203
202
|
}
|
|
204
|
-
|
|
203
|
+
catch (_b) {
|
|
204
|
+
// JSON parse failed, fall through to error handling
|
|
205
|
+
}
|
|
206
|
+
const statusText = response.statusText || `status code ${response.status}`;
|
|
207
|
+
throw new Error(`HTTP ${response.status}: ${statusText}`);
|
|
205
208
|
}
|
|
206
209
|
const responseJson = yield response.json();
|
|
207
210
|
// Record success in health tracker
|
package/lib/version.js
CHANGED