1
0
Fork 0

Fix #3940: unload all children from the plugin module on updates.

This commit is contained in:
John Livingston 2021-04-08 17:37:14 +02:00 committed by Chocobozzz
parent 4113719209
commit 09d535ef98
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 4 additions and 1 deletions

View file

@ -99,6 +99,7 @@
"cookie-parser": "^1.4.3", "cookie-parser": "^1.4.3",
"cors": "^2.8.1", "cors": "^2.8.1",
"create-torrent": "^4.0.0", "create-torrent": "^4.0.0",
"decache": "^4.6.0",
"deep-object-diff": "^1.1.0", "deep-object-diff": "^1.1.0",
"email-templates": "^8.0.3", "email-templates": "^8.0.3",
"express": "^4.12.4", "express": "^4.12.4",

View file

@ -23,6 +23,8 @@ import { ClientHtml } from '../client-html'
import { RegisterHelpers } from './register-helpers' import { RegisterHelpers } from './register-helpers'
import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn'
const decache = require('decache')
export interface RegisteredPlugin { export interface RegisteredPlugin {
npmName: string npmName: string
name: string name: string
@ -411,7 +413,7 @@ export class PluginManager implements ServerHook {
// Delete cache if needed // Delete cache if needed
const modulePath = join(pluginPath, packageJSON.library) const modulePath = join(pluginPath, packageJSON.library)
delete require.cache[modulePath] decache(modulePath)
const library: PluginLibrary = require(modulePath) const library: PluginLibrary = require(modulePath)
if (!isLibraryCodeValid(library)) { if (!isLibraryCodeValid(library)) {