fix: shallow-copy event to avoid mutating shared hook object · openclaw/openclaw@c118710
2026-04-28
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -500,13 +500,10 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
500 | 500 | handler: Parameters<typeof registerInternalHook>[1]; |
501 | 501 | }> = []; |
502 | 502 | for (const event of normalizedEvents) { |
503 | | -// Wrap handler to inject pluginConfig into event context |
504 | | -// so plugins can access their configured pluginConfig at invocation time |
505 | 503 | const wrappedHandler: typeof handler = async (evt) => { |
506 | | -if (evt.context && typeof evt.context === "object") { |
507 | | -(evt.context as Record<string, unknown>).pluginConfig = pluginConfig; |
508 | | -} |
509 | | -return handler(evt); |
| 504 | +// Shallow-copy to avoid mutating the shared event object |
| 505 | +// passed to all handlers sequentially by triggerInternalHook |
| 506 | +return handler({ ...evt, context: { ...evt.context, pluginConfig } }); |
510 | 507 | }; |
511 | 508 | registerInternalHook(event, wrappedHandler); |
512 | 509 | nextRegistrations.push({ event, handler: wrappedHandler }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。