@sentio/runtime 2.40.0-rc.32 → 2.40.0-rc.34
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/lib/{chunk-KVYXDEGV.js → chunk-PPRDWL6W.js} +11 -7
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -1
- package/lib/processor-runner.js +1 -1
- package/package.json +1 -1
- package/src/db-context.ts +9 -9
- package/src/service.ts +5 -3
@@ -59717,6 +59717,7 @@ var _StoreContext = class {
|
|
59717
59717
|
}
|
59718
59718
|
defers = /* @__PURE__ */ new Map();
|
59719
59719
|
statsInterval;
|
59720
|
+
pendings = [];
|
59720
59721
|
newPromise(opId, requestType) {
|
59721
59722
|
return new Promise((resolve, reject) => {
|
59722
59723
|
this.defers.set(opId, { resolve, reject, requestType });
|
@@ -59746,6 +59747,7 @@ var _StoreContext = class {
|
|
59746
59747
|
});
|
59747
59748
|
send_counts[requestType]?.add(1);
|
59748
59749
|
if (requestType === "upsert" && STORE_UPSERT_NO_WAIT) {
|
59750
|
+
this.pendings.push(promise);
|
59749
59751
|
return Promise.resolve({
|
59750
59752
|
opId
|
59751
59753
|
});
|
@@ -59776,10 +59778,6 @@ var _StoreContext = class {
|
|
59776
59778
|
recv_counts[defer.requestType]?.add(1);
|
59777
59779
|
}
|
59778
59780
|
if (dbResult.error) {
|
59779
|
-
if (defer.requestType == "upsert" && STORE_UPSERT_NO_WAIT) {
|
59780
|
-
console.error("upsert no_wait enabled, the error may not be thrown in user function", dbResult.error);
|
59781
|
-
throw new Error(dbResult.error);
|
59782
|
-
}
|
59783
59781
|
defer.reject(new Error(dbResult.error));
|
59784
59782
|
} else {
|
59785
59783
|
defer.resolve(dbResult);
|
@@ -59841,11 +59839,13 @@ var _StoreContext = class {
|
|
59841
59839
|
timer: timeout
|
59842
59840
|
};
|
59843
59841
|
if (STORE_UPSERT_NO_WAIT) {
|
59842
|
+
this.pendings.push(promise);
|
59844
59843
|
return {
|
59845
59844
|
opId: this.upsertBatch.opId
|
59846
59845
|
};
|
59846
|
+
} else {
|
59847
|
+
return promise;
|
59847
59848
|
}
|
59848
|
-
return promise;
|
59849
59849
|
}
|
59850
59850
|
}
|
59851
59851
|
sendBatch() {
|
@@ -59865,6 +59865,9 @@ var _StoreContext = class {
|
|
59865
59865
|
batched_total_count.add(request.entity.length);
|
59866
59866
|
}
|
59867
59867
|
}
|
59868
|
+
async awaitPendings() {
|
59869
|
+
await Promise.all(this.pendings);
|
59870
|
+
}
|
59868
59871
|
};
|
59869
59872
|
var StoreContext = _StoreContext;
|
59870
59873
|
__publicField(StoreContext, "opCounter", 0n);
|
@@ -80289,7 +80292,7 @@ var ProcessorServiceImpl = class {
|
|
80289
80292
|
} catch (e) {
|
80290
80293
|
console.error(`eth call error: ${e}`);
|
80291
80294
|
}
|
80292
|
-
console.
|
80295
|
+
console.debug(
|
80293
80296
|
`${Object.keys(results).length} calls finished, actual calls: ${callPromises.length + multicallPromises.length}, elapsed: ${Date.now() - start}ms`
|
80294
80297
|
);
|
80295
80298
|
return {
|
@@ -80407,7 +80410,8 @@ var ProcessorServiceImpl = class {
|
|
80407
80410
|
const binding = request.binding;
|
80408
80411
|
const dbContext = contexts.new(request.processId, subject);
|
80409
80412
|
const start = Date.now();
|
80410
|
-
PluginManager.INSTANCE.processBinding(binding, this.preparedData, dbContext).then((result) => {
|
80413
|
+
PluginManager.INSTANCE.processBinding(binding, this.preparedData, dbContext).then(async (result) => {
|
80414
|
+
await dbContext.awaitPendings();
|
80411
80415
|
subject.next({
|
80412
80416
|
result,
|
80413
80417
|
processId: request.processId
|
package/lib/index.d.ts
CHANGED
@@ -17,6 +17,7 @@ declare class StoreContext {
|
|
17
17
|
private static opCounter;
|
18
18
|
private defers;
|
19
19
|
private statsInterval;
|
20
|
+
private pendings;
|
20
21
|
constructor(subject: Subject<DeepPartial$1<ProcessStreamResponse>>, processId: number);
|
21
22
|
newPromise<T>(opId: bigint, requestType?: RequestType): Promise<T>;
|
22
23
|
sendRequest(request: DeepPartial$1<Request>, timeoutSecs?: number): Promise<DBResponse>;
|
@@ -31,6 +32,7 @@ declare class StoreContext {
|
|
31
32
|
} | undefined;
|
32
33
|
private sendUpsertInBatch;
|
33
34
|
private sendBatch;
|
35
|
+
awaitPendings(): Promise<void>;
|
34
36
|
}
|
35
37
|
|
36
38
|
declare abstract class Plugin {
|
package/lib/index.js
CHANGED
package/lib/processor-runner.js
CHANGED
package/package.json
CHANGED
package/src/db-context.ts
CHANGED
@@ -29,12 +29,12 @@ export const timeoutError = new Error('timeout')
|
|
29
29
|
|
30
30
|
export class StoreContext {
|
31
31
|
private static opCounter = 0n
|
32
|
-
|
33
32
|
private defers = new Map<
|
34
33
|
bigint,
|
35
34
|
{ resolve: (value: any) => void; reject: (reason?: any) => void; requestType?: RequestType }
|
36
35
|
>()
|
37
36
|
private statsInterval: NodeJS.Timeout | undefined
|
37
|
+
private pendings: Promise<unknown>[] = []
|
38
38
|
|
39
39
|
constructor(
|
40
40
|
readonly subject: Subject<DeepPartial<ProcessStreamResponse>>,
|
@@ -78,7 +78,7 @@ export class StoreContext {
|
|
78
78
|
send_counts[requestType]?.add(1)
|
79
79
|
|
80
80
|
if (requestType === 'upsert' && STORE_UPSERT_NO_WAIT) {
|
81
|
-
|
81
|
+
this.pendings.push(promise)
|
82
82
|
return Promise.resolve({
|
83
83
|
opId,
|
84
84
|
} as DBResponse)
|
@@ -115,11 +115,6 @@ export class StoreContext {
|
|
115
115
|
recv_counts[defer.requestType]?.add(1)
|
116
116
|
}
|
117
117
|
if (dbResult.error) {
|
118
|
-
if (defer.requestType == 'upsert' && STORE_UPSERT_NO_WAIT) {
|
119
|
-
console.error('upsert no_wait enabled, the error may not be thrown in user function', dbResult.error)
|
120
|
-
throw new Error(dbResult.error)
|
121
|
-
}
|
122
|
-
|
123
118
|
defer.reject(new Error(dbResult.error))
|
124
119
|
} else {
|
125
120
|
defer.resolve(dbResult)
|
@@ -197,12 +192,13 @@ export class StoreContext {
|
|
197
192
|
}
|
198
193
|
|
199
194
|
if (STORE_UPSERT_NO_WAIT) {
|
195
|
+
this.pendings.push(promise)
|
200
196
|
return {
|
201
197
|
opId: this.upsertBatch.opId
|
202
198
|
}
|
199
|
+
} else {
|
200
|
+
return promise
|
203
201
|
}
|
204
|
-
|
205
|
-
return promise
|
206
202
|
}
|
207
203
|
}
|
208
204
|
|
@@ -224,4 +220,8 @@ export class StoreContext {
|
|
224
220
|
batched_total_count.add(request.entity.length)
|
225
221
|
}
|
226
222
|
}
|
223
|
+
|
224
|
+
async awaitPendings() {
|
225
|
+
await Promise.all(this.pendings)
|
226
|
+
}
|
227
227
|
}
|
package/src/service.ts
CHANGED
@@ -256,7 +256,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
256
256
|
} catch (e) {
|
257
257
|
console.error(`eth call error: ${e}`)
|
258
258
|
}
|
259
|
-
console.
|
259
|
+
console.debug(
|
260
260
|
`${Object.keys(results).length} calls finished, actual calls: ${callPromises.length + multicallPromises.length}, elapsed: ${Date.now() - start}ms`
|
261
261
|
)
|
262
262
|
return {
|
@@ -410,7 +410,9 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
410
410
|
const dbContext = contexts.new(request.processId, subject)
|
411
411
|
const start = Date.now()
|
412
412
|
PluginManager.INSTANCE.processBinding(binding, this.preparedData, dbContext)
|
413
|
-
.then((result) => {
|
413
|
+
.then(async (result) => {
|
414
|
+
// await all pending db requests
|
415
|
+
await dbContext.awaitPendings()
|
414
416
|
subject.next({
|
415
417
|
result,
|
416
418
|
processId: request.processId
|
@@ -436,7 +438,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
436
438
|
try {
|
437
439
|
dbContext?.result(request.dbResult)
|
438
440
|
} catch (e) {
|
439
|
-
subject.error(new Error(
|
441
|
+
subject.error(new Error('db result error, process should stop'))
|
440
442
|
}
|
441
443
|
}
|
442
444
|
} catch (e) {
|