@apibara/indexer 2.1.0-beta.25 → 2.1.0-beta.27
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/index.cjs +5 -3
- package/dist/index.mjs +6 -4
- package/package.json +2 -2
- package/src/indexer.ts +9 -3
package/dist/index.cjs
CHANGED
|
@@ -108,13 +108,15 @@ async function runWithReconnect(client, indexer, options = {}) {
|
|
|
108
108
|
return;
|
|
109
109
|
} catch (error) {
|
|
110
110
|
retryCount++;
|
|
111
|
-
if (error instanceof protocol.ClientError) {
|
|
111
|
+
if (error instanceof protocol.ClientError || error instanceof protocol.ServerError) {
|
|
112
|
+
const isServerError = error instanceof protocol.ServerError;
|
|
112
113
|
if (error.code === protocol.Status.INTERNAL) {
|
|
113
114
|
if (retryCount < maxRetries) {
|
|
114
115
|
consola__default.error(
|
|
115
|
-
|
|
116
|
-
error.message
|
|
116
|
+
`Internal ${isServerError ? "server" : "client"} error: ${error.message}`
|
|
117
117
|
);
|
|
118
|
+
consola__default.start("Reconnecting...");
|
|
119
|
+
console.log();
|
|
118
120
|
const delay = Math.random() * (retryDelay * 0.2) + retryDelay;
|
|
119
121
|
await new Promise(
|
|
120
122
|
(resolve) => setTimeout(resolve, Math.min(retryCount * delay, maxWait))
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientError, Status } from '@apibara/protocol';
|
|
1
|
+
import { ClientError, ServerError, Status } from '@apibara/protocol';
|
|
2
2
|
import consola from 'consola';
|
|
3
3
|
import { createHooks, createDebugger } from 'hookable';
|
|
4
4
|
import assert from 'node:assert';
|
|
@@ -101,13 +101,15 @@ async function runWithReconnect(client, indexer, options = {}) {
|
|
|
101
101
|
return;
|
|
102
102
|
} catch (error) {
|
|
103
103
|
retryCount++;
|
|
104
|
-
if (error instanceof ClientError) {
|
|
104
|
+
if (error instanceof ClientError || error instanceof ServerError) {
|
|
105
|
+
const isServerError = error instanceof ServerError;
|
|
105
106
|
if (error.code === Status.INTERNAL) {
|
|
106
107
|
if (retryCount < maxRetries) {
|
|
107
108
|
consola.error(
|
|
108
|
-
|
|
109
|
-
error.message
|
|
109
|
+
`Internal ${isServerError ? "server" : "client"} error: ${error.message}`
|
|
110
110
|
);
|
|
111
|
+
consola.start("Reconnecting...");
|
|
112
|
+
console.log();
|
|
111
113
|
const delay = Math.random() * (retryDelay * 0.2) + retryDelay;
|
|
112
114
|
await new Promise(
|
|
113
115
|
(resolve) => setTimeout(resolve, Math.min(retryCount * delay, maxWait))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/indexer",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"vitest": "^1.6.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@apibara/protocol": "2.1.0-beta.
|
|
73
|
+
"@apibara/protocol": "2.1.0-beta.27",
|
|
74
74
|
"@opentelemetry/api": "^1.9.0",
|
|
75
75
|
"ci-info": "^4.1.0",
|
|
76
76
|
"consola": "^3.4.2",
|
package/src/indexer.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type DataFinality,
|
|
6
6
|
type Finalize,
|
|
7
7
|
type Invalidate,
|
|
8
|
+
ServerError,
|
|
8
9
|
Status,
|
|
9
10
|
type StreamConfig,
|
|
10
11
|
type StreamDataOptions,
|
|
@@ -179,13 +180,18 @@ export async function runWithReconnect<TFilter, TBlock>(
|
|
|
179
180
|
|
|
180
181
|
retryCount++;
|
|
181
182
|
|
|
182
|
-
if (error instanceof ClientError) {
|
|
183
|
+
if (error instanceof ClientError || error instanceof ServerError) {
|
|
184
|
+
const isServerError = error instanceof ServerError;
|
|
185
|
+
|
|
183
186
|
if (error.code === Status.INTERNAL) {
|
|
184
187
|
if (retryCount < maxRetries) {
|
|
185
188
|
consola.error(
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
`Internal ${isServerError ? "server" : "client"} error: ${
|
|
190
|
+
error.message
|
|
191
|
+
}`,
|
|
188
192
|
);
|
|
193
|
+
consola.start("Reconnecting...");
|
|
194
|
+
console.log();
|
|
189
195
|
|
|
190
196
|
// Add jitter to the retry delay to avoid all clients retrying at the same time.
|
|
191
197
|
const delay = Math.random() * (retryDelay * 0.2) + retryDelay;
|