Skip to content

Colors: Absturz beheben, wenn eine Verbraucher-Nachricht vor der Hierarchie-Nachricht ankommt - #4296

Open
seaspotter wants to merge 2 commits into
openWB:masterfrom
seaspotter:fix-colors-consumer-message-race
Open

seaspotter wants to merge 2 commits into
openWB:masterfrom
seaspotter:fix-colors-consumer-message-race

Conversation

@seaspotter

@seaspotter seaspotter commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

#3466 (comment): Verbraucher bleiben teilweise bei "Verbraucher" statt ihrem echten Namen, in der Konsole erscheint dabei "Uncaught TypeError: Cannot set properties of undefined".

Verbraucher werden beim Verarbeiten der "openWB/counter/get/hierarchy"-Nachricht in die consumers-Map eingetragen. Die Pro-Verbraucher-Topics (zB "module" mit dem Namen) kommen aber unabhängig davon an, nicht garantiert danach. Kommt eins davor an, hat der alte Code gewarnt und ist dann beim Versuch, einen noch nicht existierenden Verbraucher zu aktualisieren, abgestürzt - das Update ging für den Rest der Session verloren.

Fix: Verbraucher beim ersten Topic anlegen statt abzustürzen, analog zum bereits vorhandenen Muster in processDayGraphData.ts für historische Daten.

Summary by Sourcery

Handle out-of-order consumer messages safely by registering consumers from the hierarchy and replaying messages received before registration.

Bug Fixes:

  • Prevent consumer updates from crashing or being lost when device messages arrive before hierarchy registration.

Enhancements:

  • Buffer early consumer messages and replay them when the consumer is registered, preserving hierarchy-based consumer ordering and colors.

@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Add a hierarchy-registration entry point that creates consumers and replays messages buffered for them, while buffering messages for consumers not yet registered.

  • packages/modules/web_themes/colors/source/src/components/consumerList/processMessages.ts L14-31, L40-43

Uses of the API

Route hierarchy-discovered consumers through the registration entry point and update imports to use it.

  • packages/modules/web_themes/colors/source/src/assets/js/processMessages.ts L27-30, L39, L189

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@seaspotter
seaspotter requested a review from cshagen November 10, 2026 13:12

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/modules/web_themes/colors/source/src/components/consumerList/processMessages.ts" line_range="22" />
<code_context>
 	}
 	if (!consumers.has(index)) {
-		console.warn('Invalid consumer id received: ' + index)
+		addConsumer(index)
 	}
 	const dev = consumers.get(index)!
</code_context>
<issue_to_address>
**Removed consumers remain visible**

When a retained or stale per-consumer topic arrives for an ID absent from the hierarchy, `addConsumer` creates a list-visible entry, and `processHierarchy` does not remove IDs absent from the hierarchy, so the removed consumer remains as a phantom row and can shift real consumers’ colors.

Ignore unknown per-consumer IDs until they appear in the hierarchy.
</issue_to_address>

### Comment 2
<location path="packages/modules/web_themes/colors/source/src/components/consumerList/processMessages.ts" line_range="22" />
<code_context>
 	}
 	if (!consumers.has(index)) {
-		console.warn('Invalid consumer id received: ' + index)
+		addConsumer(index)
 	}
 	const dev = consumers.get(index)!
</code_context>
<issue_to_address>
**Consumer colors depend on message order**

When per-consumer messages first arrive in an order different from the hierarchy order, `addConsumer` assigns colors from `consumers.size`, so an early message fixes each consumer’s color according to arrival order. The later hierarchy call does not replace existing consumers, leaving the same consumer IDs with different colors across sessions and their graph series displayed in those inconsistent colors.

Assign consumer colors from a stable ID or explicitly apply hierarchy-order colors when the hierarchy arrives.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@cshagen cshagen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vielen Dank für den Fix !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants