@sentio/runtime 2.59.1 → 2.59.2
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/service-worker.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
2
|
-
import{a as k}from"./chunk-JPHAFAK7.js";import{$ as I,W as C,c as h,j as R,p as x,q as y,s as q}from"./chunk-
|
2
|
+
import{a as k}from"./chunk-JPHAFAK7.js";import{$ as I,W as C,c as h,j as R,p as x,q as y,s as q}from"./chunk-PEHR2WT4.js";import{e as E}from"./chunk-VUN3TGG5.js";var s=E(x(),1);var i=E(y(),1);import{threadId as o}from"worker_threads";import{Piscina as L}from"piscina";var D=E(C(),1),b=!1,u;process.on("uncaughtException",e=>{console.error("Uncaught Exception, please checking if await is properly used",e),u=e}).on("unhandledRejection",(e,t)=>{e?.message.startsWith('invalid ENS name (disallowed character: "*"')||(console.error("Unhandled Rejection, please checking if await is properly",e),u=e)}).on("exit",()=>{console.info("Worker thread exiting, threadId:",o)});var d,A=async e=>{if(e.target){let t=await import(e.target);return console.debug("Module loaded, path:",e.target,"module:",t),t}},v={};async function N(e,t){if(b)return{};q();try{d=new I(()=>A(t),t)}catch(a){throw new s.ServerError(s.Status.INVALID_ARGUMENT,"Failed to load processor: "+h(a))}return await d.start(e,v),b=!0,{}}async function z({processId:e,request:t,workerPort:a}){let{startRequest:p,configRequest:w,options:n}=L.workerData;if(!b){let r=process.env.LOG_LEVEL?.toUpperCase();k(n["log-format"]==="json",r==="debug"?!0:n.debug,o),R(n),p&&(await N(p,n),console.debug("worker",o," started, template instance:",p.templateInstances?.length)),w&&(await d?.getConfig(w,v),console.debug("worker",o," configured"))}if(u){let r=u;throw u=void 0,console.error("Unhandled exception/rejection in previous request:",r),new i.RichServerError(s.Status.UNAVAILABLE,"Unhandled exception/rejection in previous request: "+h(r),[i.DebugInfo.fromPartial({detail:r.message,stackEntries:r.stack?.split(`
|
3
3
|
`)})])}let l=n["worker-timeout"]||0,S=n["enable-partition"]||!1;await new Promise((r,P)=>{let f=new D.Subject,m;f.subscribe(c=>{console.debug("Worker",o,"send response:",c.result?"result":"dbResult"),a.postMessage(c),c.result&&(m&&clearTimeout(m),r(),a.close())}),a.on("message",c=>{let g=c;console.debug("Worker",o,"received request:",g.start?"start":"dbResult"),d?.handleRequest(g,t.binding,f),S&&g.start&&l>0&&(m=setTimeout(async()=>{P(new i.RichServerError(s.Status.DEADLINE_EXCEEDED,"Worker timeout exceeded"))},l))}),console.debug("Worker",o,"handle request: binding"),d?.handleRequest(t,t.binding,f),!S&&l>0&&(m=setTimeout(()=>{P(new i.RichServerError(s.Status.DEADLINE_EXCEEDED,"Worker timeout exceeded"))},l))})}import("node:process").then(e=>e.stdout.write(""));export{z as default};
|
4
4
|
//# sourceMappingURL=service-worker.js.map
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
@@ -21,11 +21,12 @@ export function mergeProcessResultsInPlace(
|
|
21
21
|
for (const r of results) {
|
22
22
|
// not using spread operator since it puts all element on the stack
|
23
23
|
// cause maximum call stack size exceeded error if it's a large array
|
24
|
-
|
25
|
-
mergeArrayInPlace(res.
|
26
|
-
mergeArrayInPlace(res.
|
27
|
-
mergeArrayInPlace(res.
|
28
|
-
mergeArrayInPlace(res.
|
24
|
+
|
25
|
+
res.counters = mergeArrayInPlace(res.counters, r.counters)
|
26
|
+
res.gauges = mergeArrayInPlace(res.gauges, r.gauges)
|
27
|
+
res.events = mergeArrayInPlace(res.events, r.events)
|
28
|
+
res.exports = mergeArrayInPlace(res.exports, r.exports)
|
29
|
+
res.timeseriesResult = mergeArrayInPlace(res.timeseriesResult, r.timeseriesResult)
|
29
30
|
res.states = {
|
30
31
|
configUpdated: res.states?.configUpdated || r.states?.configUpdated || false
|
31
32
|
}
|
@@ -33,10 +34,14 @@ export function mergeProcessResultsInPlace(
|
|
33
34
|
return res
|
34
35
|
}
|
35
36
|
|
36
|
-
function mergeArrayInPlace<T>(dst: T[], src: T[]) {
|
37
|
-
|
38
|
-
|
37
|
+
function mergeArrayInPlace<T>(dst: T[], src: T[]): T[] {
|
38
|
+
const res = dst || []
|
39
|
+
if (Array.isArray(src)) {
|
40
|
+
for (const r of src) {
|
41
|
+
res.push(r)
|
42
|
+
}
|
39
43
|
}
|
44
|
+
return res
|
40
45
|
}
|
41
46
|
|
42
47
|
export function errorString(e: Error): string {
|