From d852bde2a5fb078828157e4e86e9ea64de46d4ce Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Thu, 24 Jul 2025 11:53:30 +0200 Subject: [PATCH] Fix: plugin loader cache not matching on decoupled plugin paths (#108529) * fix(plugins): match decoupled plugin path in fe plugin loader cache * chore(devenv): update local_cdn to work with latest changes in core * refactor(plugins): improve legibility by splitting regexs into two * revert(devenv): revert -oss removal in local_cdn rewrite path --- devenv/local_cdn/default.conf | 2 +- public/app/features/plugins/loader/cache.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/devenv/local_cdn/default.conf b/devenv/local_cdn/default.conf index e35c16ee146..0c37c5ff410 100644 --- a/devenv/local_cdn/default.conf +++ b/devenv/local_cdn/default.conf @@ -19,6 +19,6 @@ server { add_header 'Access-Control-Allow-Headers' '*' always; add_header 'Access-Control-Allow-Credentials' 'true' always; - rewrite ^/grafana-oss/11.4.0-pre/public(.*)$ $1 last; + rewrite ^/grafana-oss/12.1.0-pre/public(.*)$ $1 last; } } diff --git a/public/app/features/plugins/loader/cache.ts b/public/app/features/plugins/loader/cache.ts index 00e77489efd..877d7fc485b 100644 --- a/public/app/features/plugins/loader/cache.ts +++ b/public/app/features/plugins/loader/cache.ts @@ -54,7 +54,20 @@ export function getPluginFromCache(path: string): CachedPlugin | undefined { export function extractCacheKeyFromPath(path: string) { const regex = /\/?public\/plugins\/([^\/]+)\//; const match = path.match(regex); - return match ? match[1] : null; + + if (match) { + return match[1]; + } + + // Decoupled core plugins can be loaded by alternative paths + const decoupledPluginRegex = /\/?public\/app\/plugins\/(?:datasource|panel)\/([^\/]+)\//; + const decoupledPluginMatch = path.match(decoupledPluginRegex); + + if (decoupledPluginMatch) { + return decoupledPluginMatch[1]; + } + + return null; } function getCacheKey(address: string): string | undefined {