mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
7a47187e37
* feat(plugins): add isolated plugin host runtime * test(plugins): build runtime dependencies before tests * fix(plugins): harden runtime lifecycle and recovery * fix(plugins): harden runtime extension boundaries * fix(plugins): enforce runtime integrity boundaries * fix(plugins): await utility process exit * fix(plugins): harden utility process containment * fix(plugins): close runtime recovery gaps * fix(plugins): harden runtime lifecycle boundaries
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
const { isPluginDevelopmentEnabled } = require("./constants.cjs");
|
|
|
|
function startDevelopmentPluginHost(options) {
|
|
if (!isPluginDevelopmentEnabled(options.env)) return null;
|
|
const reportFailure = (message, error) => {
|
|
try { options.logger?.error?.(message, error); } catch {}
|
|
};
|
|
let service;
|
|
try {
|
|
service = options.createService();
|
|
const initialization = Promise.resolve(service.manager.initialize());
|
|
options.registerShutdown(() => service.manager.shutdown());
|
|
void initialization.catch(async (error) => {
|
|
reportFailure("[Plugins] Failed to initialize plugin host:", error);
|
|
try {
|
|
await service.manager.shutdown();
|
|
} catch (shutdownError) {
|
|
reportFailure("[Plugins] Failed to close unavailable plugin host:", shutdownError);
|
|
}
|
|
});
|
|
return service;
|
|
} catch (error) {
|
|
reportFailure("[Plugins] Failed to create plugin host:", error);
|
|
if (typeof service?.manager?.shutdown === "function") {
|
|
try { void Promise.resolve(service.manager.shutdown()).catch(() => {}); } catch {}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
module.exports = { startDevelopmentPluginHost };
|