Unload stale modules from electron cache
Summary: `requirePlugin` in electron uses native `require` which has a built-in cache. Without this fix a stale version of the plugin loaded. Reviewed By: lblasa Differential Revision: D39542121 fbshipit-source-id: e6c4b65f9ea7b816803baaae537c234914fcb3d7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6b3298a29e
commit
fab4ee8c22
@@ -160,6 +160,7 @@ async function processPluginCommandsQueue(
|
||||
|
||||
async function loadPlugin(store: Store, payload: LoadPluginActionPayload) {
|
||||
try {
|
||||
unloadPluginModule(payload.plugin);
|
||||
const plugin = await requirePlugin(payload.plugin);
|
||||
const enablePlugin = payload.enable;
|
||||
updatePlugin(store, {plugin, enablePlugin});
|
||||
@@ -292,7 +293,6 @@ function updateClientPlugin(
|
||||
.connections.enabledPlugins[c.query.app]?.includes(plugin.id)
|
||||
);
|
||||
});
|
||||
const previousVersion = store.getState().plugins.clientPlugins.get(plugin.id);
|
||||
clientsWithEnabledPlugin.forEach((client) => {
|
||||
stopPlugin(client, plugin.id);
|
||||
});
|
||||
@@ -300,10 +300,6 @@ function updateClientPlugin(
|
||||
startPlugin(client, plugin, true);
|
||||
});
|
||||
store.dispatch(pluginLoaded(plugin));
|
||||
if (previousVersion) {
|
||||
// unload previous version from Electron cache
|
||||
unloadPluginModule(previousVersion.details);
|
||||
}
|
||||
}
|
||||
|
||||
function updateDevicePlugin(
|
||||
@@ -321,11 +317,6 @@ function updateDevicePlugin(
|
||||
devicesWithEnabledPlugin.forEach((d) => {
|
||||
d.unloadDevicePlugin(plugin.id);
|
||||
});
|
||||
const previousVersion = store.getState().plugins.devicePlugins.get(plugin.id);
|
||||
if (previousVersion) {
|
||||
// unload previous version from Electron cache
|
||||
unloadPluginModule(previousVersion.details);
|
||||
}
|
||||
store.dispatch(pluginLoaded(plugin));
|
||||
devicesWithEnabledPlugin.forEach((d) => {
|
||||
d.loadDevicePlugin(plugin);
|
||||
|
||||
Reference in New Issue
Block a user