bug: RBAC loader logs "plugin found but failed to load" when @triggerdotdev/plugins is simply not installed

未關閉 適合新手
#5,083 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@itsfaryal 已經在處理了。

開始於 2026年10月28日。

  • #5102 來自 @cocvn157 —— 已關閉,未合併

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
82/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript
領域
authorization

研究方向

從 internal-packages/rbac/src/index.ts 的第 167-209 行附近開始,這裡會將 ERR_MODULE_NOT_FOUND 訊息與 @triggerdotdev/plugins/rbac 比較,以判斷外掛本身是否缺失。透過在 Node 中嘗試對一個未安裝的套件進行動態匯入來重現訊息形態,然後放寬缺失外掛的檢查,使其也符合加上引號的套件名稱,同時讓已安裝但損壞的外掛仍然大聲報錯。對 internal-packages/sso/src/index.ts(第 60-93 行)和 internal-packages/billing/src/index.ts(第 78 行)中的載入器套用同樣的變更;當三者對缺失的套件都保持靜默,但對存在但損壞的套件仍然記錄錯誤時即完成。

由索引模型根據 Issue 內容生成。

描述

Provide environment information

Self-hosted, official Helm chart 4.8.1 (image ghcr.io/triggerdotdev/trigger.dev:v4.8.1) on Kubernetes 1.35. The plugins package is not installed, which is the normal state for a self-hosted install. REQUIRE_PLUGINS and RBAC_LOG_FALLBACK are not set.

Describe the bug

On every webapp boot a self-hosted instance logs this at error level:

RBAC: plugin found but failed to load; falling back to default implementation Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@triggerdotdev/plugins' imported from /triggerdotdev/apps/webapp/build/server/assets/server-build-<hash>.js

The plugin was not found, it is simply not installed. Per the comments in the loader, that case should be silent unless RBAC_LOG_FALLBACK=1, and the "found but failed to load" error is meant only for a plugin that is present but broken.

The cause is the check that tells the two cases apart (rbac/src/index.ts#L167-L209):

const moduleName = "@triggerdotdev/plugins/rbac";
// ...
const isPluginItselfMissing = isModuleNotFound && message.includes(moduleName);

When the whole package is absent, Node's error names only the package, not the subpath: Cannot find package '@triggerdotdev/plugins'. So message.includes("@triggerdotdev/plugins/rbac") is false, and the missing plugin is classified as a broken one.

The SSO and billing loaders use the same check (sso/src/index.ts#L60-L93, billing/src/index.ts#L78). We only saw the RBAC line, presumably because those load lazily. The code is unchanged on main.

Expected: no error log when @triggerdotdev/plugins is not installed.

Reproduction repo

N/A: reproduces with the official chart/image; code links above.

To reproduce
  1. Install or upgrade the official Helm chart 4.8.1 (any self-hosted install without @triggerdotdev/plugins).
  2. kubectl -n <ns> logs deploy/<release>-webapp -c webapp | grep RBAC
  3. See the "plugin found but failed to load" error on each boot.
Suggested fix

Also accept the quoted package name when deciding whether the plugin itself is missing, e.g.

const isPluginItselfMissing =
  isModuleNotFound &&
  (message.includes(moduleName) || message.includes("'@triggerdotdev/plugins'"));

and the same in the SSO and billing loaders. Matching the quoted name, not the bare one, keeps a broken plugin loud: if an installed plugin's own dependency is missing, the message quotes that dependency's name, and @triggerdotdev/plugins appears only unquoted in the imported from path.

Additional information

Harmless at runtime (the fallback is the documented self-hosted behaviour), but an error-level line on every boot sends self-hosters looking for a broken install.

主要語言
TypeScript
星號
16.5k
分支
1.5k
平均合併
1 天 15 小時
30 天內合併 PR
17

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

triggerdotdev/trigger.dev 的其他 Issue

查看 triggerdotdev/trigger.dev 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。