fix: 🥅 fix a plugin loading error
While reloading, plugin cache may not be deleted. This happens when a loaded plugin encounters an error during reload. This causes a deadlock in the unloading code. So make sure cache is always deleted: - ignore when an `unload()` function doesn't exist - delete cache even if there are no `exports`
This commit is contained in:
		| @@ -47,7 +47,9 @@ function unloadplugin(pluginname, pluginpath) { | ||||
|     const plugin = require.resolve(pluginpath) | ||||
|     try { | ||||
|         if (plugin && require.cache[plugin]) { | ||||
|             require.cache[plugin].exports.unload() | ||||
|             // `unload()` isn't exported sometimes, | ||||
|             // when plugin isn't properly loaded | ||||
|             require.cache[plugin].exports?.unload?.() | ||||
|             delete plugins[pluginname] | ||||
|             delete require.cache[plugin] | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user