@sentio/runtime 2.57.12-rc.e → 2.57.12-rc.f
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-YVOMEKB4.js → chunk-IAGVEBAE.js} +1797 -5192
- package/lib/chunk-IAGVEBAE.js.map +1 -0
- package/lib/{chunk-6YBY6GSE.js → chunk-XR3EZ6FB.js} +448 -479
- package/lib/chunk-XR3EZ6FB.js.map +1 -0
- package/lib/index.d.ts +50 -136
- package/lib/index.js +2 -2
- package/lib/processor-runner.js +757 -1159
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.js +23 -23
- package/lib/service-worker.js.map +1 -1
- package/package.json +1 -1
- package/src/service-manager.ts +2 -2
- package/src/service-worker.ts +24 -24
- package/lib/chunk-6YBY6GSE.js.map +0 -1
- package/lib/chunk-YVOMEKB4.js.map +0 -1
package/lib/service-worker.js
CHANGED
@@ -5,12 +5,12 @@ import {
|
|
5
5
|
recordRuntimeInfo,
|
6
6
|
require_lib2 as require_lib,
|
7
7
|
require_lib3 as require_lib2
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-IAGVEBAE.js";
|
9
9
|
import {
|
10
10
|
PluginManager,
|
11
11
|
ProcessConfigResponse,
|
12
12
|
__toESM
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-XR3EZ6FB.js";
|
14
14
|
|
15
15
|
// src/service-worker.ts
|
16
16
|
var import_nice_grpc = __toESM(require_lib(), 1);
|
@@ -63,29 +63,29 @@ async function start(request, options) {
|
|
63
63
|
return {};
|
64
64
|
}
|
65
65
|
async function service_worker_default({ request }) {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
try {
|
67
|
+
if (!started) {
|
68
|
+
const { startRequest, configRequest, options } = Piscina.workerData;
|
69
|
+
if (startRequest) {
|
70
|
+
await start(startRequest, options);
|
71
|
+
}
|
72
|
+
if (configRequest) {
|
73
|
+
await getConfig(configRequest);
|
74
|
+
}
|
75
|
+
console.info("new processor worker started");
|
70
76
|
}
|
71
|
-
if (
|
72
|
-
|
77
|
+
if (unhandled) {
|
78
|
+
throw new import_nice_grpc_error_details.RichServerError(
|
79
|
+
import_nice_grpc.Status.UNAVAILABLE,
|
80
|
+
"Unhandled exception/rejection in previous request: " + errorString(unhandled),
|
81
|
+
[
|
82
|
+
import_nice_grpc_error_details.DebugInfo.fromPartial({
|
83
|
+
detail: unhandled.message,
|
84
|
+
stackEntries: unhandled.stack?.split("\n")
|
85
|
+
})
|
86
|
+
]
|
87
|
+
);
|
73
88
|
}
|
74
|
-
console.info("new processor worker started");
|
75
|
-
}
|
76
|
-
if (unhandled) {
|
77
|
-
throw new import_nice_grpc_error_details.RichServerError(
|
78
|
-
import_nice_grpc.Status.UNAVAILABLE,
|
79
|
-
"Unhandled exception/rejection in previous request: " + errorString(unhandled),
|
80
|
-
[
|
81
|
-
import_nice_grpc_error_details.DebugInfo.fromPartial({
|
82
|
-
detail: unhandled.message,
|
83
|
-
stackEntries: unhandled.stack?.split("\n")
|
84
|
-
})
|
85
|
-
]
|
86
|
-
);
|
87
|
-
}
|
88
|
-
try {
|
89
89
|
const result = await PluginManager.INSTANCE.processBinding(
|
90
90
|
request,
|
91
91
|
void 0
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/service-worker.ts"],"sourcesContent":["import {\n DataBinding,\n Empty,\n HandlerType,\n PreparedData,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessResult,\n StartRequest\n} from '@sentio/protos'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { PluginManager } from './plugin.js'\nimport commandLineArgs from 'command-line-args'\nimport { optionDefinitions } from './processor-runner.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 } from 'worker_threads'\nimport { Piscina } from 'piscina'\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,
|
1
|
+
{"version":3,"sources":["../src/service-worker.ts"],"sourcesContent":["import {\n DataBinding,\n Empty,\n HandlerType,\n PreparedData,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessResult,\n StartRequest\n} from '@sentio/protos'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { PluginManager } from './plugin.js'\nimport commandLineArgs from 'command-line-args'\nimport { optionDefinitions } from './processor-runner.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 } from 'worker_threads'\nimport { Piscina } from 'piscina'\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 ({ request }: { request: DataBinding }) {\n try {\n if (!started) {\n const { startRequest, configRequest, options } = Piscina.workerData\n if (startRequest) {\n await start(startRequest, options)\n }\n if (configRequest) {\n await getConfig(configRequest)\n }\n console.info('new processor worker started')\n }\n\n if (unhandled) {\n throw new RichServerError(\n Status.UNAVAILABLE,\n 'Unhandled exception/rejection in previous request: ' + errorString(unhandled),\n [\n DebugInfo.fromPartial({\n detail: unhandled.message,\n stackEntries: unhandled.stack?.split('\\n')\n })\n ]\n )\n }\n\n const result = await PluginManager.INSTANCE.processBinding(\n request,\n undefined\n // PluginManager.INSTANCE.dbContextLocalStorage.getStore()\n )\n recordRuntimeInfo(result, request.handlerType)\n return result\n } catch (e) {\n console.error('worker process binding failed', e)\n throw e\n }\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;;;;;;;AAUA,uBAAiD;AAMjD,qCAA2C;AAE3C,SAAS,wBAAwB;AACjC,SAAS,eAAe;AAExB,IAAI,UAAU;AAEd,IAAI;AAEJ,QACG,GAAG,qBAAqB,CAAC,QAAQ;AAChC,UAAQ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AAA,MAC/B;AACA,cAAQ,KAAK,8BAA8B;AAAA,IAC7C;AAEA,QAAI,WAAW;AACb,YAAM,IAAI;AAAA,QACR,wBAAO;AAAA,QACP,wDAAwD,YAAY,SAAS;AAAA,QAC7E;AAAA,UACE,yCAAU,YAAY;AAAA,YACpB,QAAQ,UAAU;AAAA,YAClB,cAAc,UAAU,OAAO,MAAM,IAAI;AAAA,UAC3C,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,cAAc,SAAS;AAAA,MAC1C;AAAA,MACA;AAAA;AAAA,IAEF;AACA,sBAAkB,QAAQ,QAAQ,WAAW;AAC7C,WAAO;AAAA,EACT,SAAS,GAAG;AACV,YAAQ,MAAM,iCAAiC,CAAC;AAChD,UAAM;AAAA,EACR;AACF;AACC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
|
package/package.json
CHANGED
package/src/service-manager.ts
CHANGED
@@ -199,7 +199,7 @@ export class ServiceManager implements ProcessorServiceImplementation {
|
|
199
199
|
|
200
200
|
const binding = request.binding
|
201
201
|
// todo support db request
|
202
|
-
|
202
|
+
const dbContext = contexts.new(request.processId, subject)
|
203
203
|
const start = Date.now()
|
204
204
|
await this.processBinding(binding)
|
205
205
|
.then(async (result) => {
|
@@ -212,7 +212,7 @@ export class ServiceManager implements ProcessorServiceImplementation {
|
|
212
212
|
})
|
213
213
|
.catch((e) => {
|
214
214
|
console.debug(e)
|
215
|
-
|
215
|
+
dbContext.error(request.processId, e)
|
216
216
|
process_binding_error.add(1)
|
217
217
|
})
|
218
218
|
.finally(() => {
|
package/src/service-worker.ts
CHANGED
@@ -51,7 +51,7 @@ async function getConfig(request: ProcessConfigRequest, context?: CallContext):
|
|
51
51
|
const loader = async (options: any) => {
|
52
52
|
if (options.target) {
|
53
53
|
const m = await import(options.target)
|
54
|
-
console.debug('Module loaded, path:', options.target,
|
54
|
+
console.debug('Module loaded, path:', options.target, 'module:', m)
|
55
55
|
return m
|
56
56
|
}
|
57
57
|
}
|
@@ -79,31 +79,31 @@ async function start(request: StartRequest, options: any): Promise<Empty> {
|
|
79
79
|
}
|
80
80
|
|
81
81
|
export default async function ({ request }: { request: DataBinding }) {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
82
|
+
try {
|
83
|
+
if (!started) {
|
84
|
+
const { startRequest, configRequest, options } = Piscina.workerData
|
85
|
+
if (startRequest) {
|
86
|
+
await start(startRequest, options)
|
87
|
+
}
|
88
|
+
if (configRequest) {
|
89
|
+
await getConfig(configRequest)
|
90
|
+
}
|
91
|
+
console.info('new processor worker started')
|
89
92
|
}
|
90
|
-
console.info('new processor worker started')
|
91
|
-
}
|
92
93
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
94
|
+
if (unhandled) {
|
95
|
+
throw new RichServerError(
|
96
|
+
Status.UNAVAILABLE,
|
97
|
+
'Unhandled exception/rejection in previous request: ' + errorString(unhandled),
|
98
|
+
[
|
99
|
+
DebugInfo.fromPartial({
|
100
|
+
detail: unhandled.message,
|
101
|
+
stackEntries: unhandled.stack?.split('\n')
|
102
|
+
})
|
103
|
+
]
|
104
|
+
)
|
105
|
+
}
|
105
106
|
|
106
|
-
try {
|
107
107
|
const result = await PluginManager.INSTANCE.processBinding(
|
108
108
|
request,
|
109
109
|
undefined
|
@@ -112,7 +112,7 @@ export default async function ({ request }: { request: DataBinding }) {
|
|
112
112
|
recordRuntimeInfo(result, request.handlerType)
|
113
113
|
return result
|
114
114
|
} catch (e) {
|
115
|
-
console.error(
|
115
|
+
console.error('worker process binding failed', e)
|
116
116
|
throw e
|
117
117
|
}
|
118
118
|
}
|