fix(diagnostics): use globalThis registry to fix plugin event isolation#7038
Closed
fangxiu-wf wants to merge 2 commits intoopenclaw:mainfrom
Closed
fix(diagnostics): use globalThis registry to fix plugin event isolation#7038fangxiu-wf wants to merge 2 commits intoopenclaw:mainfrom
fangxiu-wf wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Fixes openclaw#5190 The diagnostics-otel plugin was unable to receive events because jiti creates separate module caches when loading plugins. This caused the plugin and gateway to use different instances of the listeners Set. Solution: Use globalThis.__openclaw_diagnostic_state__ to store shared state (listeners Set and seq counter) across all module instances. - Wrap listeners and seq in DiagnosticGlobalState on globalThis - Ensure plugins loaded via jiti share the same event emitter - Maintain backward compatibility with existing API - All tests passing (578 tests)
Author
|
I hope this pull request can be merged before the next release. Combined with PR #4255, this will provide a complete fix for OpenClaw's observability capabilities. |
…lation Fixes openclaw#12473 The logging system used module-level state (loggingState object and externalTransports Set) that can be duplicated when plugins are loaded via jiti, causing registered log transports from plugins to be invisible to the main process. This is architecturally identical to the issue fixed in openclaw#5190 for diagnostic events. Solution: Use Symbol.for('openclaw.logging.state') to store shared state (including externalTransports Set) across all module instances. Changes: - Refactor src/logging/state.ts to use global registry pattern - Move externalTransports from module-level to global state - Update all access points in src/logging/logger.ts - Fix plugin-sdk export to reference correct type location - All tests passing (236 tests)
Member
|
Closing as duplicate of #11168. If this is incorrect, comment and we can reopen. |
Author
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5190
The diagnostics-otel plugin was unable to receive events because jiti creates separate module caches when loading plugins. This caused the plugin and gateway to use different instances of the listeners Set.
Solution: Use globalThis.openclaw_diagnostic_state to store shared state (listeners Set and seq counter) across all module instances.
Greptile Overview
Greptile Summary
This PR changes diagnostics event dispatch to store its shared emitter state (
listenersandseq) onglobalThisso that plugins loaded via separate module caches (e.g., through jiti) still observe and emit into the same listener set.Implementation is localized to
src/infra/diagnostic-events.ts, replacing module-levelseq/listenerswith agetGlobalState()accessor that initializes and returns a process-global state object.Confidence Score: 4/5
globalThis. Main risk is unintended cross-instance sharing/collisions in long-lived processes, but functionality should improve for the stated plugin/jiti scenario.(2/5) Greptile learns from your feedback when you react with thumbs up/down!