Skip to content

Commit 8e072df

Browse files
committed
refactor: allow nodejs engine unload
1 parent 55338cc commit 8e072df

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/lse/PluginManager.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ ll::Expected<> PluginManager::load(ll::plugin::Manifest manifest) {
202202
ExitEngineScope exit;
203203
#endif
204204
plugin->onLoad([](ll::plugin::Plugin& plugin) { return true; });
205-
#ifndef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
206205
plugin->onUnload([](ll::plugin::Plugin& plugin) { return true; });
207-
#endif
208206
plugin->onEnable([](ll::plugin::Plugin& plugin) { return true; });
209207
plugin->onDisable([](ll::plugin::Plugin& plugin) { return true; });
210208
} catch (const Exception& e) {
@@ -241,16 +239,21 @@ ll::Expected<> PluginManager::unload(std::string_view name) {
241239

242240
auto& scriptEngine = *EngineManager::getEngine(std::string(name));
243241

242+
#ifndef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
244243
LLSERemoveTimeTaskData(&scriptEngine);
244+
#endif
245245
LLSERemoveAllEventListeners(&scriptEngine);
246246
LLSERemoveCmdRegister(&scriptEngine);
247247
LLSERemoveCmdCallback(&scriptEngine);
248248
LLSERemoveAllExportedFuncs(&scriptEngine);
249249

250250
scriptEngine.getData().reset();
251251
EngineManager::unregisterEngine(&scriptEngine);
252+
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
253+
NodeJsHelper::stopEngine(&scriptEngine);
254+
#else
252255
scriptEngine.destroy(); // TODO: use unique_ptr to manage the engine.
253-
erasePlugin(name);
256+
#endif
254257
return {};
255258
} catch (const std::exception& e) {
256259
return ll::makeStringError("Failed to unload plugin {}: {}"_tr(name, e.what()));

0 commit comments

Comments
 (0)