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:
parent
f50e388c39
commit
d001280383
|
@ -47,7 +47,9 @@ function unloadplugin(pluginname, pluginpath) {
|
||||||
const plugin = require.resolve(pluginpath)
|
const plugin = require.resolve(pluginpath)
|
||||||
try {
|
try {
|
||||||
if (plugin && require.cache[plugin]) {
|
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 plugins[pluginname]
|
||||||
delete require.cache[plugin]
|
delete require.cache[plugin]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user