From 0460374af060ed2fa2786de3acd8e12466b3b2df Mon Sep 17 00:00:00 2001 From: Eric <45801973+waresnew@users.noreply.github.com> Date: Wed, 15 May 2024 21:46:09 -0400 Subject: [PATCH 1/2] Fix: Plugins without start/stop function failing to stop/start (#2463) --- src/plugins/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 3291885c1..a434b4a6f 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -170,13 +170,14 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p: } try { p.start(); - p.started = true; } catch (e) { logger.error(`Failed to start ${name}\n`, e); return false; } } + p.started = true; + if (commands?.length) { logger.debug("Registering commands of plugin", name); for (const cmd of commands) { @@ -206,6 +207,7 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p: export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plugin) { const { name, commands, flux, contextMenus } = p; + if (p.stop) { logger.info("Stopping plugin", name); if (!p.started) { @@ -214,13 +216,14 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu } try { p.stop(); - p.started = false; } catch (e) { logger.error(`Failed to stop ${name}\n`, e); return false; } } + p.started = false; + if (commands?.length) { logger.debug("Unregistering commands of plugin", name); for (const cmd of commands) { From c0c897fc237df5e60be759966a12c8e2478ee9ef Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 15 May 2024 23:00:21 -0300 Subject: [PATCH 2/2] extractAndLoadChunksLazy: Cache result to avoid searching factories everytime --- src/webpack/webpack.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 8ea6713d0..0bee08f32 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { proxyLazy } from "@utils/lazy"; +import { makeLazy, proxyLazy } from "@utils/lazy"; import { LazyComponent } from "@utils/lazyReact"; import { Logger } from "@utils/Logger"; import { canonicalizeMatch } from "@utils/patches"; @@ -462,7 +462,7 @@ export async function extractAndLoadChunks(code: string[], matcher: RegExp = Def export function extractAndLoadChunksLazy(code: string[], matcher = DefaultExtractAndLoadChunksRegex) { if (IS_DEV) lazyWebpackSearchHistory.push(["extractAndLoadChunks", [code, matcher]]); - return () => extractAndLoadChunks(code, matcher); + return makeLazy(() => extractAndLoadChunks(code, matcher)); } /**