@sentio/runtime 2.58.1 → 2.58.2-rc.1

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.
@@ -1,4 +1,130 @@
1
1
  import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
2
- import{a as R}from"./chunk-QVIDLAYP.js";import{T as C,_ as P,b as d,i as w,o as y,p as A,r as E}from"./chunk-LHDBKJ2B.js";import{e as m,q as h,u}from"./chunk-NEX6GJVW.js";var o=m(y(),1);var p=m(A(),1);import{BroadcastChannel as I,threadId as N}from"worker_threads";import{Piscina as b}from"piscina";var l=!1,a;process.on("uncaughtException",e=>{console.error("Uncaught Exception, please checking if await is properly used",e),a=e}).on("unhandledRejection",(e,r)=>{e?.message.startsWith('invalid ENS name (disallowed character: "*"')||(console.error("Unhandled Rejection, please checking if await is properly",e),a=e)});async function S(e,r){if(!l)throw new o.ServerError(o.Status.UNAVAILABLE,"Service Not started.");let t=h.fromPartial({});return await u.INSTANCE.configure(t),t}var L=async e=>{if(e.target){let r=await import(e.target);return console.debug("Module loaded, path:",e.target,"module:",r),r}},q=new I("configure_channel");q.onmessage=e=>{S(e)};async function D(e,r){if(l)return{};E();try{await L(r)}catch(t){throw new o.ServerError(o.Status.INVALID_ARGUMENT,"Failed to load processor: "+d(t))}return await u.INSTANCE.start(e),l=!0,{}}async function X({request:e,processId:r,workerPort:t}){let{startRequest:n,configRequest:i,options:c}=b.workerData;if(!l){let s=process.env.LOG_LEVEL?.toUpperCase();R(c["log-format"]==="json",s==="debug"?!0:c.debug,N),w(c),n&&(await D(n,c),console.debug("worker started, template instance:",n.templateInstances?.length)),i&&(await S(i),console.debug("worker configured"))}if(a){let s=a;throw a=void 0,new p.RichServerError(o.Status.UNAVAILABLE,"Unhandled exception/rejection in previous request: "+d(s),[p.DebugInfo.fromPartial({detail:s.message,stackEntries:s.stack?.split(`
3
- `)})])}let g=await u.INSTANCE.processBinding(e,void 0,t?new f(t,r):void 0);return P(g,e.handlerType),g}var f=class extends C{constructor(t,n){super(n);this.port=t;this.port.on("message",i=>{this.result(i)}),this.port.on("close",()=>{this.close()})}doSend(t){this.port.postMessage(t)}};import("node:process").then(e=>e.stdout.write(""));export{X as default};
2
+ import {
3
+ setupLogger
4
+ } from "./chunk-BPGFX5S5.js";
5
+ import {
6
+ AbstractStoreContext,
7
+ configureEndpoints,
8
+ errorString,
9
+ freezeGlobalConfig,
10
+ recordRuntimeInfo,
11
+ require_lib3 as require_lib,
12
+ require_lib4 as require_lib2
13
+ } from "./chunk-NLEBXJPP.js";
14
+ import {
15
+ PluginManager,
16
+ ProcessConfigResponse,
17
+ __toESM
18
+ } from "./chunk-ZUTD563J.js";
19
+
20
+ // src/service-worker.ts
21
+ var import_nice_grpc = __toESM(require_lib(), 1);
22
+ var import_nice_grpc_error_details = __toESM(require_lib2(), 1);
23
+ import { BroadcastChannel, threadId } from "worker_threads";
24
+ import { Piscina } from "piscina";
25
+ var started = false;
26
+ var unhandled;
27
+ process.on("uncaughtException", (err) => {
28
+ console.error("Uncaught Exception, please checking if await is properly used", err);
29
+ unhandled = err;
30
+ }).on("unhandledRejection", (reason, p) => {
31
+ if (reason?.message.startsWith('invalid ENS name (disallowed character: "*"')) {
32
+ return;
33
+ }
34
+ console.error("Unhandled Rejection, please checking if await is properly", reason);
35
+ unhandled = reason;
36
+ });
37
+ async function getConfig(request, context) {
38
+ if (!started) {
39
+ throw new import_nice_grpc.ServerError(import_nice_grpc.Status.UNAVAILABLE, "Service Not started.");
40
+ }
41
+ const newConfig = ProcessConfigResponse.fromPartial({});
42
+ await PluginManager.INSTANCE.configure(newConfig);
43
+ return newConfig;
44
+ }
45
+ var loader = async (options) => {
46
+ if (options.target) {
47
+ const m = await import(options.target);
48
+ console.debug("Module loaded, path:", options.target, "module:", m);
49
+ return m;
50
+ }
51
+ };
52
+ var configureChannel = new BroadcastChannel("configure_channel");
53
+ configureChannel.onmessage = (request) => {
54
+ getConfig(request);
55
+ };
56
+ async function start(request, options) {
57
+ if (started) {
58
+ return {};
59
+ }
60
+ freezeGlobalConfig();
61
+ try {
62
+ await loader(options);
63
+ } catch (e) {
64
+ throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "Failed to load processor: " + errorString(e));
65
+ }
66
+ await PluginManager.INSTANCE.start(request);
67
+ started = true;
68
+ return {};
69
+ }
70
+ async function service_worker_default({
71
+ request,
72
+ processId,
73
+ workerPort
74
+ }) {
75
+ const { startRequest, configRequest, options } = Piscina.workerData;
76
+ if (!started) {
77
+ const logLevel = process.env["LOG_LEVEL"]?.toUpperCase();
78
+ setupLogger(options["log-format"] === "json", logLevel === "debug" ? true : options.debug, threadId);
79
+ configureEndpoints(options);
80
+ if (startRequest) {
81
+ await start(startRequest, options);
82
+ console.debug("worker started, template instance:", startRequest.templateInstances?.length);
83
+ }
84
+ if (configRequest) {
85
+ await getConfig(configRequest);
86
+ console.debug("worker configured");
87
+ }
88
+ }
89
+ if (unhandled) {
90
+ const err = unhandled;
91
+ unhandled = void 0;
92
+ throw new import_nice_grpc_error_details.RichServerError(
93
+ import_nice_grpc.Status.UNAVAILABLE,
94
+ "Unhandled exception/rejection in previous request: " + errorString(err),
95
+ [
96
+ import_nice_grpc_error_details.DebugInfo.fromPartial({
97
+ detail: err.message,
98
+ stackEntries: err.stack?.split("\n")
99
+ })
100
+ ]
101
+ );
102
+ }
103
+ const result = await PluginManager.INSTANCE.processBinding(
104
+ request,
105
+ void 0,
106
+ workerPort ? new WorkerStoreContext(workerPort, processId) : void 0
107
+ );
108
+ recordRuntimeInfo(result, request.handlerType);
109
+ return result;
110
+ }
111
+ var WorkerStoreContext = class extends AbstractStoreContext {
112
+ constructor(port, processId) {
113
+ super(processId);
114
+ this.port = port;
115
+ this.port.on("message", (resp) => {
116
+ this.result(resp);
117
+ });
118
+ this.port.on("close", () => {
119
+ this.close();
120
+ });
121
+ }
122
+ doSend(req) {
123
+ this.port.postMessage(req);
124
+ }
125
+ };
126
+ import("node:process").then((p) => p.stdout.write(""));
127
+ export {
128
+ service_worker_default as default
129
+ };
4
130
  //# sourceMappingURL=service-worker.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/service-worker.ts"],"sourcesContent":["import {\n DataBinding,\n DBResponse,\n DeepPartial,\n Empty,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessStreamResponse,\n StartRequest\n} from '@sentio/protos'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { PluginManager } from './plugin.js'\nimport { errorString } from './utils.js'\nimport { freezeGlobalConfig } from './global-config.js'\nimport { DebugInfo, RichServerError } from 'nice-grpc-error-details'\nimport { recordRuntimeInfo } from './service.js'\nimport { BroadcastChannel, MessagePort, threadId } from 'worker_threads'\nimport { Piscina } from 'piscina'\nimport { configureEndpoints } from './endpoints.js'\nimport { setupLogger } from './logger.js'\nimport { AbstractStoreContext } from './db-context.js'\n\nlet started = false\n\nlet unhandled: Error | undefined\n\nprocess\n .on('uncaughtException', (err) => {\n console.error('Uncaught Exception, please checking if await is properly used', err)\n unhandled = err\n })\n .on('unhandledRejection', (reason, p) => {\n // @ts-ignore ignore invalid ens error\n if (reason?.message.startsWith('invalid ENS name (disallowed character: \"*\"')) {\n return\n }\n console.error('Unhandled Rejection, please checking if await is properly', reason)\n unhandled = reason as Error\n // shutdownServers(1)\n })\n\nasync function getConfig(request: ProcessConfigRequest, context?: CallContext): Promise<ProcessConfigResponse> {\n if (!started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const newConfig = ProcessConfigResponse.fromPartial({})\n await PluginManager.INSTANCE.configure(newConfig)\n return newConfig\n}\n\nconst loader = async (options: any) => {\n if (options.target) {\n const m = await import(options.target)\n console.debug('Module loaded, path:', options.target, 'module:', m)\n return m\n }\n}\n\nconst configureChannel = new BroadcastChannel('configure_channel')\nconfigureChannel.onmessage = (request: ProcessConfigRequest) => {\n getConfig(request)\n}\n\nasync function start(request: StartRequest, options: any): Promise<Empty> {\n if (started) {\n return {}\n }\n freezeGlobalConfig()\n\n try {\n await loader(options)\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n await PluginManager.INSTANCE.start(request)\n started = true\n return {}\n}\n\nexport default async function ({\n request,\n processId,\n workerPort\n}: {\n request: DataBinding\n processId: number\n workerPort?: MessagePort\n}) {\n const { startRequest, configRequest, options } = Piscina.workerData\n if (!started) {\n const logLevel = process.env['LOG_LEVEL']?.toUpperCase()\n setupLogger(options['log-format'] === 'json', logLevel === 'debug' ? true : options.debug, threadId)\n\n configureEndpoints(options)\n\n if (startRequest) {\n await start(startRequest, options)\n console.debug('worker started, template instance:', startRequest.templateInstances?.length)\n }\n\n if (configRequest) {\n await getConfig(configRequest)\n console.debug('worker configured')\n }\n }\n\n if (unhandled) {\n const err = unhandled\n unhandled = undefined\n throw new RichServerError(\n Status.UNAVAILABLE,\n 'Unhandled exception/rejection in previous request: ' + errorString(err),\n [\n DebugInfo.fromPartial({\n detail: err.message,\n stackEntries: err.stack?.split('\\n')\n })\n ]\n )\n }\n\n const result = await PluginManager.INSTANCE.processBinding(\n request,\n undefined,\n workerPort ? new WorkerStoreContext(workerPort, processId) : undefined\n )\n recordRuntimeInfo(result, request.handlerType)\n return result\n}\n\nclass WorkerStoreContext extends AbstractStoreContext {\n constructor(\n readonly port: MessagePort,\n processId: number\n ) {\n super(processId)\n this.port.on('message', (resp: DBResponse) => {\n this.result(resp)\n })\n this.port.on('close', () => {\n this.close()\n })\n }\n\n doSend(req: DeepPartial<ProcessStreamResponse>): void {\n this.port.postMessage(req)\n }\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";2KAUA,IAAAA,EAAiD,SAIjD,IAAAC,EAA2C,SAE3C,OAAS,oBAAAC,EAA+B,YAAAC,MAAgB,iBACxD,OAAS,WAAAC,MAAe,UAKxB,IAAIC,EAAU,GAEVC,EAEJ,QACG,GAAG,oBAAsBC,GAAQ,CA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gB,CAAQ,EAEnGC,EAAmBjB,CAAO,EAEtBW,IACF,MAAMP,EAAMO,EAAcX,CAAO,EACjC,QAAQ,MAAM,qCAAsCW,EAAa,mBAAmB,MAAM,GAGxFC,IACF,MAAMnB,EAAUmB,CAAa,EAC7B,QAAQ,MAAM,mBAAmB,EAErC,CAEA,GAAIvB,EAAW,CACb,IAAMC,EAAMD,EACZ,MAAAA,EAAY,OACN,IAAI,kBACR,SAAO,YACP,sDAAwDkB,EAAYjB,CAAG,EACvE,CACE,YAAU,YAAY,CACpB,OAAQA,EAAI,QACZ,aAAcA,EAAI,OAAO,MAAM;AAAA,CAAI,CACrC,CAAC,CACH,CACF,CACF,CAEA,IAAM4B,EAAS,MAAMpB,EAAc,SAAS,eAC1CJ,EACA,OACAgB,EAAa,IAAIS,EAAmBT,EAAYD,CAAS,EAAI,MAC/D,EACA,OAAAW,EAAkBF,EAAQxB,EAAQ,WAAW,EACtCwB,CACT,CAEA,IAAMC,EAAN,cAAiCE,CAAqB,CACpD,YACWC,EACTb,EACA,CACA,MAAMA,CAAS,EAHN,UAAAa,EAIT,KAAK,KAAK,GAAG,UAAYC,GAAqB,CAC5C,KAAK,OAAOA,CAAI,CAClB,CAAC,EACD,KAAK,KAAK,GAAG,QAAS,IAAM,CAC1B,KAAK,MAAM,CACb,CAAC,CACH,CAEA,OAAOC,EAA+C,CACpD,KAAK,KAAK,YAAYA,CAAG,CAC3B,CACF,EACC,OAAO,cAAc,EAAE,KAAMhC,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC","names":["import_nice_grpc","import_nice_grpc_error_details","BroadcastChannel","threadId","Piscina","started","unhandled","err","reason","p","getConfig","request","context","newConfig","ProcessConfigResponse","PluginManager","loader","options","m","configureChannel","BroadcastChannel","start","freezeGlobalConfig","e","errorString","service_worker_default","processId","workerPort","startRequest","configRequest","Piscina","logLevel","setupLogger","threadId","configureEndpoints","result","WorkerStoreContext","recordRuntimeInfo","AbstractStoreContext","port","resp","req"]}
1
+ {"version":3,"sources":["../src/service-worker.ts"],"sourcesContent":["import {\n DataBinding,\n DBResponse,\n DeepPartial,\n Empty,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessStreamResponse,\n StartRequest\n} from '@sentio/protos'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { PluginManager } from './plugin.js'\nimport { errorString } from './utils.js'\nimport { freezeGlobalConfig } from './global-config.js'\nimport { DebugInfo, RichServerError } from 'nice-grpc-error-details'\nimport { recordRuntimeInfo } from './service.js'\nimport { BroadcastChannel, MessagePort, threadId } from 'worker_threads'\nimport { Piscina } from 'piscina'\nimport { configureEndpoints } from './endpoints.js'\nimport { setupLogger } from './logger.js'\nimport { AbstractStoreContext } from './db-context.js'\n\nlet started = false\n\nlet unhandled: Error | undefined\n\nprocess\n .on('uncaughtException', (err) => {\n console.error('Uncaught Exception, please checking if await is properly used', err)\n unhandled = err\n })\n .on('unhandledRejection', (reason, p) => {\n // @ts-ignore ignore invalid ens error\n if (reason?.message.startsWith('invalid ENS name (disallowed character: \"*\"')) {\n return\n }\n console.error('Unhandled Rejection, please checking if await is properly', reason)\n unhandled = reason as Error\n // shutdownServers(1)\n })\n\nasync function getConfig(request: ProcessConfigRequest, context?: CallContext): Promise<ProcessConfigResponse> {\n if (!started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const newConfig = ProcessConfigResponse.fromPartial({})\n await PluginManager.INSTANCE.configure(newConfig)\n return newConfig\n}\n\nconst loader = async (options: any) => {\n if (options.target) {\n const m = await import(options.target)\n console.debug('Module loaded, path:', options.target, 'module:', m)\n return m\n }\n}\n\nconst configureChannel = new BroadcastChannel('configure_channel')\nconfigureChannel.onmessage = (request: ProcessConfigRequest) => {\n getConfig(request)\n}\n\nasync function start(request: StartRequest, options: any): Promise<Empty> {\n if (started) {\n return {}\n }\n freezeGlobalConfig()\n\n try {\n await loader(options)\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n await PluginManager.INSTANCE.start(request)\n started = true\n return {}\n}\n\nexport default async function ({\n request,\n processId,\n workerPort\n}: {\n request: DataBinding\n processId: number\n workerPort?: MessagePort\n}) {\n const { startRequest, configRequest, options } = Piscina.workerData\n if (!started) {\n const logLevel = process.env['LOG_LEVEL']?.toUpperCase()\n setupLogger(options['log-format'] === 'json', logLevel === 'debug' ? true : options.debug, threadId)\n\n configureEndpoints(options)\n\n if (startRequest) {\n await start(startRequest, options)\n console.debug('worker started, template instance:', startRequest.templateInstances?.length)\n }\n\n if (configRequest) {\n await getConfig(configRequest)\n console.debug('worker configured')\n }\n }\n\n if (unhandled) {\n const err = unhandled\n unhandled = undefined\n throw new RichServerError(\n Status.UNAVAILABLE,\n 'Unhandled exception/rejection in previous request: ' + errorString(err),\n [\n DebugInfo.fromPartial({\n detail: err.message,\n stackEntries: err.stack?.split('\\n')\n })\n ]\n )\n }\n\n const result = await PluginManager.INSTANCE.processBinding(\n request,\n undefined,\n workerPort ? new WorkerStoreContext(workerPort, processId) : undefined\n )\n recordRuntimeInfo(result, request.handlerType)\n return result\n}\n\nclass WorkerStoreContext extends AbstractStoreContext {\n constructor(\n readonly port: MessagePort,\n processId: number\n ) {\n super(processId)\n this.port.on('message', (resp: DBResponse) => {\n this.result(resp)\n })\n this.port.on('close', () => {\n this.close()\n })\n }\n\n doSend(req: DeepPartial<ProcessStreamResponse>): void {\n this.port.postMessage(req)\n }\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;;;;;;;;;;;;AAUA,uBAAiD;AAIjD,qCAA2C;AAE3C,SAAS,kBAA+B,gBAAgB;AACxD,SAAS,eAAe;AAKxB,IAAI,UAAU;AAEd,IAAI;AAEJ,QACG,GAAG,qBAAqB,CAAC,QAAQ;AAChC,UAAQ,MAAM,iEAAiE,GAAG;AAClF,cAAY;AACd,CAAC,EACA,GAAG,sBAAsB,CAAC,QAAQ,MAAM;AAEvC,MAAI,QAAQ,QA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O;AACjC,cAAQ,MAAM,sCAAsC,aAAa,mBAAmB,MAAM;AAAA,IAC5F;AAEA,QAAI,eAAe;AACjB,YAAM,UAAU,aAAa;AAC7B,cAAQ,MAAM,mBAAmB;AAAA,IACnC;AAAA,EACF;AAEA,MAAI,WAAW;AACb,UAAM,MAAM;AACZ,gBAAY;AACZ,UAAM,IAAI;AAAA,MACR,wBAAO;AAAA,MACP,wDAAwD,YAAY,GAAG;AAAA,MACvE;AAAA,QACE,yCAAU,YAAY;AAAA,UACpB,QAAQ,IAAI;AAAA,UACZ,cAAc,IAAI,OAAO,MAAM,IAAI;AAAA,QACrC,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,MAAM,cAAc,SAAS;AAAA,IAC1C;AAAA,IACA;AAAA,IACA,aAAa,IAAI,mBAAmB,YAAY,SAAS,IAAI;AAAA,EAC/D;AACA,oBAAkB,QAAQ,QAAQ,WAAW;AAC7C,SAAO;AACT;AAEA,IAAM,qBAAN,cAAiC,qBAAqB;AAAA,EACpD,YACW,MACT,WACA;AACA,UAAM,SAAS;AAHN;AAIT,SAAK,KAAK,GAAG,WAAW,CAAC,SAAqB;AAC5C,WAAK,OAAO,IAAI;AAAA,IAClB,CAAC;AACD,SAAK,KAAK,GAAG,SAAS,MAAM;AAC1B,WAAK,MAAM;AAAA,IACb,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,KAA+C;AACpD,SAAK,KAAK,YAAY,GAAG;AAAA,EAC3B;AACF;AACC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/test-processor.test.ts"],"sourcesContent":["import { Plugin, PluginManager } from './plugin.js'\nimport { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'\n\nclass TestPlugin extends Plugin {\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n const dbContext = PluginManager.INSTANCE.dbContextLocalStorage.getStore()\n if (dbContext) {\n await dbContext.sendRequest({\n get: {\n entity: 'Test',\n id: '1'\n }\n })\n }\n\n return ProcessResult.fromPartial({\n states: {\n configUpdated: true\n }\n })\n }\n supportedHandlers = [HandlerType.UNKNOWN, HandlerType.ETH_LOG]\n}\n\nPluginManager.INSTANCE.plugins = []\nPluginManager.INSTANCE.register(new TestPlugin())\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";sDAGA,IAAMA,EAAN,cAAyBC,CAAO,CAC9B,MAAM,eAAeC,EAA8C,CACjE,IAAMC,EAAYC,EAAc,SAAS,sBAAsB,SAAS,EACxE,OAAID,GACF,MAAMA,EAAU,YAAY,CAC1B,IAAK,CACH,OAAQ,OACR,GAAI,GACN,CACF,CAAC,EAGIE,EAAc,YAAY,CAC/B,OAAQ,CACN,cAAe,EACjB,CACF,CAAC,CACH,CACA,kBAAoB,IAAyC,CAC/D,EAEAD,EAAc,SAAS,QAAU,CAAC,EAClCA,EAAc,SAAS,SAAS,IAAIJ,CAAY,EAC/C,OAAO,cAAc,EAAE,KAAMM,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC","names":["TestPlugin","Plugin","request","dbContext","PluginManager","ProcessResult","p"]}
1
+ {"version":3,"sources":["../src/test-processor.test.ts"],"sourcesContent":["import { Plugin, PluginManager } from './plugin.js'\nimport { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'\n\nclass TestPlugin extends Plugin {\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n const dbContext = PluginManager.INSTANCE.dbContextLocalStorage.getStore()\n if (dbContext) {\n await dbContext.sendRequest({\n get: {\n entity: 'Test',\n id: '1'\n }\n })\n }\n\n return ProcessResult.fromPartial({\n states: {\n configUpdated: true\n }\n })\n }\n supportedHandlers = [HandlerType.UNKNOWN, HandlerType.ETH_LOG]\n}\n\nPluginManager.INSTANCE.plugins = []\nPluginManager.INSTANCE.register(new TestPlugin())\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;AAGA,IAAM,aAAN,cAAyB,OAAO;AAAA,EAC9B,MAAM,eAAe,SAA8C;AACjE,UAAM,YAAY,cAAc,SAAS,sBAAsB,SAAS;AACxE,QAAI,WAAW;AACb,YAAM,UAAU,YAAY;AAAA,QAC1B,KAAK;AAAA,UACH,QAAQ;AAAA,UACR,IAAI;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO,cAAc,YAAY;AAAA,MAC/B,QAAQ;AAAA,QACN,eAAe;AAAA,MACjB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EACA,oBAAoB,iCAAyC;AAC/D;AAEA,cAAc,SAAS,UAAU,CAAC;AAClC,cAAc,SAAS,SAAS,IAAI,WAAW,CAAC;AAC/C,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "2.58.1",
3
+ "version": "2.58.2-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,6 +21,7 @@ import { setupLogger } from './logger.js'
21
21
  import { setupOTLP } from './otlp.js'
22
22
  import { ActionServer } from './action-server.js'
23
23
  import { ServiceManager } from './service-manager.js'
24
+ import path from 'path'
24
25
 
25
26
  // const mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry])
26
27
 
@@ -185,13 +186,15 @@ process
185
186
 
186
187
  if (process.env['OOM_DUMP_MEMORY_SIZE_GB']) {
187
188
  let dumping = false
188
- const memorySize = parseInt(process.env['OOM_DUMP_MEMORY_SIZE_GB'], 10)
189
+ const memorySize = parseFloat(process.env['OOM_DUMP_MEMORY_SIZE_GB'])
189
190
  console.log('heap dumping is enabled, limit set to ', memorySize, 'gb')
191
+ const dir = process.env['OOM_DUMP_DIR'] || '/tmp'
190
192
  setInterval(async () => {
191
193
  const mem = process.memoryUsage()
194
+ console.log('Current Memory Usage', mem)
192
195
  // if memory usage is greater this size, dump heap and exit
193
196
  if (mem.heapTotal > memorySize * 1024 * 1024 * 1024 && !dumping) {
194
- const file = '/tmp/' + Date.now() + '.heapsnapshot'
197
+ const file = path.join(dir, `${Date.now()}.heapsnapshot`)
195
198
  dumping = true
196
199
  await dumpHeap(file)
197
200
  // force exit and keep pod running
@@ -203,6 +206,7 @@ if (process.env['OOM_DUMP_MEMORY_SIZE_GB']) {
203
206
  async function dumpHeap(file: string) {
204
207
  console.log('Heap dumping to', file)
205
208
  const session = new Session()
209
+ fs.mkdirSync(path.dirname(file), { recursive: true })
206
210
  const fd = fs.openSync(file, 'w')
207
211
  try {
208
212
  session.connect()