aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohn Livingston <git@john-livingston.fr>2021-04-08 17:37:14 +0200
committerChocobozzz <me@florianbigard.com>2021-04-09 09:32:16 +0200
commit09d535ef9817a63096dc724cc4d9f0671ee6e5a3 (patch)
tree2a897a30774cb55eed96126d23c3bdab07065b6e
parent41137192096590b171563bc3161ede6f5c1d15db (diff)
downloadPeerTube-09d535ef9817a63096dc724cc4d9f0671ee6e5a3.tar.gz
PeerTube-09d535ef9817a63096dc724cc4d9f0671ee6e5a3.tar.zst
PeerTube-09d535ef9817a63096dc724cc4d9f0671ee6e5a3.zip
Fix #3940: unload all children from the plugin module on updates.
-rw-r--r--package.json1
-rw-r--r--server/lib/plugins/plugin-manager.ts4
2 files changed, 4 insertions, 1 deletions
diff --git a/package.json b/package.json
index e3766e318..e6ae0a27e 100644
--- a/package.json
+++ b/package.json
@@ -99,6 +99,7 @@
99 "cookie-parser": "^1.4.3", 99 "cookie-parser": "^1.4.3",
100 "cors": "^2.8.1", 100 "cors": "^2.8.1",
101 "create-torrent": "^4.0.0", 101 "create-torrent": "^4.0.0",
102 "decache": "^4.6.0",
102 "deep-object-diff": "^1.1.0", 103 "deep-object-diff": "^1.1.0",
103 "email-templates": "^8.0.3", 104 "email-templates": "^8.0.3",
104 "express": "^4.12.4", 105 "express": "^4.12.4",
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index c19b40135..0086a0e2e 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -23,6 +23,8 @@ import { ClientHtml } from '../client-html'
23import { RegisterHelpers } from './register-helpers' 23import { RegisterHelpers } from './register-helpers'
24import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' 24import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn'
25 25
26const decache = require('decache')
27
26export interface RegisteredPlugin { 28export interface RegisteredPlugin {
27 npmName: string 29 npmName: string
28 name: string 30 name: string
@@ -411,7 +413,7 @@ export class PluginManager implements ServerHook {
411 413
412 // Delete cache if needed 414 // Delete cache if needed
413 const modulePath = join(pluginPath, packageJSON.library) 415 const modulePath = join(pluginPath, packageJSON.library)
414 delete require.cache[modulePath] 416 decache(modulePath)
415 const library: PluginLibrary = require(modulePath) 417 const library: PluginLibrary = require(modulePath)
416 418
417 if (!isLibraryCodeValid(library)) { 419 if (!isLibraryCodeValid(library)) {