Skip to content

Commit a3ffc80

Browse files
committed
fix: fixes issue 1444 invoking the onPluginInit
In api server the instantiatePlugin function is now calling the required onPluginInit for each corresponding connector Closes: hyperledger-cacti#1444 Signed-off-by: Michael Courtin <[email protected]>
1 parent 3cf5200 commit a3ffc80

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/cactus-cmd-api-server/src/main/typescript/api-server.ts

+20
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,26 @@ export class ApiServer {
332332
const pluginFactory = await createPluginFactory(pluginFactoryOptions);
333333

334334
const plugin = await pluginFactory.create(pluginOptions);
335+
336+
// need to invoke the i-cactus-plugin onPluginInit functionality here before plugin registry can be used further
337+
try {
338+
await plugin.onPluginInit();
339+
} catch (error) {
340+
const fnTag = `${this.className}#instantiatePlugin`;
341+
const packageName = plugin.getPackageName();
342+
const instanceId = plugin.getInstanceId();
343+
344+
const errorMessage = `${fnTag} failed calling onPluginInit() on the plugin '${packageName}' with the instanceId '${instanceId}'`;
345+
346+
this.log.error(errorMessage, error);
347+
348+
if (error instanceof Error) {
349+
throw new RuntimeError(errorMessage, error);
350+
} else {
351+
throw new RuntimeError(errorMessage, JSON.stringify(error));
352+
}
353+
}
354+
335355
return plugin;
336356
}
337357

0 commit comments

Comments
 (0)